VSCode: error TS5042: Option ‘project’ cannot be mixed with source files on a command line.

I have been using VSCode a lot lately. I have recently started delving into TypeScript and wanted to use VSCode to begin developing my first project. I was following a tutorial on Lynda.com and for the life of me could not get it to “transpile” my TS project. I setup everything according to this site and it failed. What I kept getting was this error:

error TS5042: Option ‘project’ cannot be mixed with source files on a command line.

This error is all over the web and not a single solution helped. I am guessing it is caused by the fact I have VS2015, VS2017, and VSCode installed on my box. But, this is the weird thing, if I go to the PowerShell in the Terminal window and paste the EXACT command that VSCode uses… IT WORKS!!! What? I started puling my hair out at this point…

Ok, now that really sucked. So, I got fed up and just build my own tasks.json using the “Other” option and here is what I entered:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "DaveCra TSC Task for VSCode",
            "command": "tsc -p tsconfig.json",
            "type": "shell",
            "problemMatcher": [
                "$tsc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Once I set this up, it was the default build task and a CTRL+SHIFT+B ran fine. Right after that I was able to go to the PowerShell terminal and type “node ” and it ran like a charm. wlEmoticon-hotsmile.png