Ad

Compile Typescript With A Visual Studio Code Task, Specifying The Output Directory

I have this task in visual studio code which compiles my typescript files. I would like to make a cleaner file structure by adding all typescript to one folder and all javascript to another folder. How do I change the args of my task to do that? My current code causes it to compile the output to be in the same folder as the typescript. Here is current 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": "silent",

    // args is the HelloWorld program to compile.
    "args": [
        "scripts/front_end/view_models/search_filter_view_model.ts",
        "scripts/front_end/models/area_getter.ts",
         "scripts/front_end/bootstrap_app.ts",
         "scripts/front_end/models/category.ts",
         "scripts/front_end/plugins/slideshow.ts"
    ],

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

Answer

I am not sure what is happening in your project. But here is what I am using in my tsconfig.json used for my angular projects. You might want to use this as a sample for your project and modify accordingly. outDir and outFile is what you need I guess.

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": false,
    "outDir":"client/build/",
    "outFile": "client/build/all.js",
    "declaration": true
  },
  "exclude": [
    "node_modules",
    "server"
  ],
  "include": [
        "client/*.ts",
        "client/**/*.ts",
        "client/**/**/*.ts"
  ]   
}

// Include all folders to put to a file.
/*    "outDir":"client/build/",
    "outFile": "client/build/all.js" */
Ad
source: stackoverflow.com
Ad