Atom-typescript option “compileOnSave”: false doesn't work


#1

I’m trying to disable compilation on save that occurs from atom-typescript plugin, so far I found compileOnSave but when I edit my tsconfig.json file to be the following:

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "compileOnSave": false
  },
  "exclude": [
    "node_modules"
  ]
}

I get an error in typescript console saying Unknown Option: compileOnSave and whole plugin stops working.

Am I using this feature incorrectly or missing something out?


#2

You could go to the atom-typescript repo and do a search for compileOnSave and variations.


#3

I did, and this seems to be correct implementation, hence I am confused to why it stops plugin from working? (I am on latest available version as well)


#4

Gave you asked about this at the typescript repo issues? We can only help so much here. It might even be a bug.


#5

The compileOnSave option belongs at the top level, between compilerOptions and exclude:

{
    "compilerOptions": { ... },
    "compileOnSave": false,
    "exclude": [ ... ]
}

#6

Yes, you are right. The compileOnSave option is a top level part of the tsconfig.json file, not part of the compilerOptions hash. But why do you say that compileOnSave goes between compilerOptions and exclude? Is there something somewhere that specifies that those three things must be in that order?

The reason I ask is, I am trying out the new ng-cli Angular 2 CLI scaffolding application and using Atom for my editor, of course. But this generates a tsconfig.json file that places compileOnSave: false before compilerOptions, and when I save a Typescript file it generates an unwanted js file in the same directory. But when I changed tsconfig.json by moving compileOnSave to the middle, between compilerOptions and exclude, as you suggest, it fixed the bug and everything worked fine.

The Typescript documentation on the tsconfig.json file doesn’t mention a specific order but shows compileOnSave before compilerOptions in the following snippet:

 {
   "compileOnSave": true,
   "compilerOptions": {
       "noImplicitAny" : true
   }
}

But since your assertion that compileOnSave belonged in the middle resolved my problem, I am curious where you got that from.