IsmaH IsmaH - 2 months ago 7
TypeScript Question

How to compile typescript files in a specific folder with Angular Quickstart

I've used Angular Quickstart example as a beginning for my angular 2 application. I'm currently trying to compile files in a separate directory to avoid the mess of

.ts
and
.js
files being mixed and I didn't a way to do it with the tools proposed.

I would like to know if anyone has met the problem before switching to a regular gulp/grunt compilation.

Answer

I had this same problem. Check it out in this issue someone raised. Link to Github issue

Simply specify the directory (outDir) in tsconfig.json like shown below.

{
    "version": "1.7.3",
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true,
        "removeComments": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "noEmitOnError": false,
        "preserveConstEnums": true,
        "inlineSources": false,
        "sourceMap": false,
        "outDir": "./dist",
        "rootDir": "./src",
        "project": "./src",
        "moduleResolution": "node",
        "listFiles": false
    },
    "exclude": [
        "node_modules",
        "jspm_packages",
        "typings/browser",
        "typings/browser.d.ts"
    ]
}

Comments