Vilches Felipe
Vilches Felipe

Reputation: 63

How to compile several Typescript files on Visual Studio Code

I'm on Linux, Visual Studio Code. I have a project that has several .ts (typescript) files, and I need to compile them all at once.

The problem is that I have those files in the /src folder, and I want to compile them to another folder, so I have to also specify the output folder.

Thanks

Upvotes: 0

Views: 910

Answers (2)

basarat
basarat

Reputation: 275987

so I have to also specify the output folder.

Use outDir in tsconfig.json

Only using tasks.json

Then provide --outDir dirPath as a flag to tsc.

Upvotes: 2

CoderPi
CoderPi

Reputation: 13211

tsconfig.json

{
    "compilerOptions": {
        "sourceMap":  true, 
        "outFile": "main.js"
    },
    "files": [
        "main.ts",
        "car.ts"
    ]
}

tasks.json

You have to OMIT the "args" option inside "tasks.json", only then will the arguments in tsconfig.json be used! I found the answer here: http://github.com/Microsoft/typescript/wiki/tsconfig.json. It says: When input files are specified on the command line, tsconfig.json files are ignored

from https://stackoverflow.com/a/33874319/4339170

Upvotes: 0

Related Questions