How can I get the Typescript compiler to output the compiled js to a different directory? How can I get the Typescript compiler to output the compiled js to a different directory? typescript typescript

How can I get the Typescript compiler to output the compiled js to a different directory?


Use the option --outDir on tsc (configured within the File Watcher in IntelliJ)

From the command line documentation

--outDir DIRECTORY Redirect output structure to the directory.

Edit

Since Typescript 1.5, this can also be set in the tsconfig.json file:

"compilerOptions": {    "outDir": "DIRECTORY"    ...


Or, add "outDir": "build"to tsconfig.json file


Though these answers are correct you should consider whether you actually just want to hide your .js files from your IDE.

In Visual Studio Code, go to File > Preferences > Settings or your .vscode\settings.json file and enter:

"files.exclude": {    "**/.git": true,    "**/.DS_Store": true,    "**/*.js" : {        "when": "$(basename).ts"    },    "**/*.js.map": {        "when": "$(basename)"    }}

The above hides .js files where a corresponding .ts file exists.