0

I have Angular2 rc5 setup in VS2015 with MVC6 also installed. I've been having issues with Typescript compileOnSave setting in tsconfig.json. I've been through all of the fixes I could find including changing the version of typescript in my PATH environmental variable, it is now running 1.8.x instead of 1.0.x. I've tried settings in VS options to compile on save which didn't seem to make a difference. I've tried using the watch setting in tsconfig.json which causes a compile error for me.

I decided to use the gulp-watch and the gulp-typescript feature to have Gulp do it all and while I was testing that out I realized that when I delete any .js files in the "outDir" folder set in my tsconfig.json file it recreates ALL of the .js files automatically. I know this is typescript performing this operation since when I change the outDir setting it does it in that folder instead. Now if I set compileOnSave to false it still does this auto creation of the .js files. The odd thing is that it will recreate ALL of the .js files even if I only delete one of them. I was able to figure that out with gulp-watch using the 'change' and 'add' events.

My question is, is this normal for it to recreate all the js and js.map files every time one of the js files gets deleted? More importantly, how can I get it to compileOnSave as it's supposed to do?

Here's my tsconfig.json file

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

-- UPDATE --

I believe I have this issue resolved. It appears that if you used this method prescribed for issues with VS2015 typescript errors on compile ex) Invalid module name in augmentation, module '../../Observable' cannot be found, it will cause this compileOnSave problem. I undid the file swap I made and all is well. I believe this is a solution found in the Angular VS2015 quickstart so this could affect a few people.

1 Answer 1

1

I appears that if you use this solution: https://github.com/Microsoft/TypeScript/issues/8518#issuecomment-229506507 to fix the "Invalid module name in augmentation, module '../../Observable' cannot be found." issue that is common with vs2015 and various versions of Angular (I'm using rc5) it can break the Typescript "compileOnSave" feature. After undoing the fix my compileOnSave started working again.

My solution for both problems was to upgrade to Typescript 2.0 beta. So far this has fixed all my issues and hasn't introduced any.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.