SSS SSS - 2 months ago 18
TypeScript Question

Atom takes much time to compile typescript files for angular 2

I am working on the Angular 2 RC-6 from Angular2 Documentation. I find atom too slow to compile my '.ts' files. If I move my tsconfig.json from root folder to any other directory, it compiles fast but misses some DI such as 'rxjs/add/operator/toPromise'.

Please suggest how to make atom compile fast, or any modification on the tsconfig.json.

My project directory structure is as instructed in documentation.

Here is my tscongig.json file

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}

Answer

Like Daniel said you just need to exclude a few folders. Mainly the node_modules folder, since there are tons of TypeScript and Javascript files in there.

You can do so by adding the following exclude option to your tsconfig.json:

"exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
]

Adding this to your current config it would look like this:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}