#Declarations files are not overwritten with allowJs and emitDeclarationOnly

3 messages · Page 1 of 1 (latest)

gloomy wave
#

I have JS project where I want to add TS annotations and emit declarations. tl;dr:

{
  "compilerOptions": {
    "declaration": true,
    "emitDeclarationOnly": true,
    "allowJs": true,
    "checkJs": true
  }
}

When I run tsc the first time, all is good. *.d.ts are created next to the JS files. However, when I run again, the declarations are not updated. Why?

pallid epoch
#

@gloomy wave I think TS's precedence for same-named files is .ts -> .d.ts -> .js : some people hand-write .d.ts files for .js files so TS will use a .d.ts file in preference to a .js file.

#

I think you may need to either clean the .d.ts files out before running tsc again or use an outDir