Reputation: 379
I am trying to setup VSC with Typescript, but I can't get VSC to compile all *.ts files with Ctrl + Shift + B.
I have gone through numerous tutorials on how to setup Typescript with VSC and I didn't manage to succeed.
My tsconfig.json file (located in root) looks like:
{
"compilerOptions": {
"target": "ES5",
"module": "amd",
"sourceMap": true,
"outFile": "all.js"
}
}
And tasks.json file (located in root/.vscode):
{
"version": "0.1.0",
"command": "tsc", // it should be tsc.cmd instead of tsc
"isShellCommand": true,
"showOutput": "silent",
"args": [ ],
"problemMatcher": "$tsc"
}
When I put "args": ["${file}"], then it compiles the current file, not in all.js, but in typescript-file-name.js, like it ignores tsconfig file.
Can VSC compile all *.ts file with its own task runner and how to set it up?
UPDATE
As I've said, I've tried many tutorials that said to leave args empty, to put "-p", "." inside it, to use npm install -g typescript, to check path variables... None of that worked.
Thing that was missing was tsc.cmd in tasks.json for the command.
If anyone knows, I would like to know why it wasn't working with "command": "tsc" when even the comment in the tasks.json file for that command line states:
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
Upvotes: 3
Views: 3034
Reputation: 1
Assuming your tsconfig.json is set to use tsc, the solution to this problem is: in command mode in your project root folder, enter tsc-w
Upvotes: 0
Reputation: 14567
I believe you should change the args command like something like this.
Notice I changed my command to point at a local tsc version but that doesn't really matter. The important stuff is in the args
option: ["-p", "."]
{
"version": "0.1.0",
"command": "${cwd}/node_modules/.bin/tsc.cmd",
"isShellCommand": true,
"showOutput": "silent",
"args": ["-p", "."],
"problemMatcher": "$tsc"
}
Upvotes: 1