Vladimir Amiorkov Vladimir Amiorkov - 2 months ago 13
TypeScript Question

How to configure VS Code's "tasks.json" to build all .ts files

Its possible this has been asked before if so I am sorry for the duplicate post simply redirect me to the other thread.

Is it possible to configure VS Code's "tasks.json" to compile all .ts files in the folder. I know I can add the path to the .ts file manually like this:

"args": [ HelloWorld.ts ],


and it does compile the HelloWorld.ts correctly but I cannot figure out how to setup the tasks.json that all.ts files in the folder are compiled.

I have looked at some tutorials which all suggest to simply remove the "HelloWorld.ts" but that does not work as no .ts files are compiled at all.

Here is the entire tasks.json file that I have in VS Code:

{
"version": "0.1.0",

// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",

// The command is a shell script
"isShellCommand": true,

// Show the output window only if unrecognized errors occur.
"showOutput": "always",

// args is the HelloWorld program to compile.
"args": [ "HelloWorld.ts" ],

// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}

Answer

As @mishap said but what his answer was missing was that there should be an empty space for the "args" like so:

"args": [ ]

rather than:

"args": []

As those args are passed to the cmd/terminal executing the tsc it is important that there is a space " " in the "args" of the tasks.json.

Comments