0
votes

I have a small typescript project and created the tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "sourceMap": true
  },
  "files": [
    "./typings/index.d.ts"
  ]
}

Two files app.ts and hero.ts contain typescript code.

tsc -p . does not trigger any compilation.

tsc hero.ts app.ts triggers the compilation.

I cannot tell why tsc -p . does not work.

Context

I installed typescript using npm.

% which tsc ...path_to_project/node_modules/.bin/tsc

The dependencies section of my package.json

  "dependencies": {
    "backbone": "^1.3.3",
    "backbone.localstorage": "^2.0.0",
    "jquery": "^3.2.1",
    "typescript": "^2.3.4"
  },
1

1 Answers

1
votes

Your files aren't being compiled because you've set the files property in your .tsconfig as

 "files": [
    "./typings/index.d.ts"
  ] 

By using the files property you're telling the compiler to compile only these files. Either remove the files property altogether or add your app.ts and hero.ts files

If the files property is excluded then the compiler defaults to including all typescript files.

Furthermore:

When input files are specified on the command line, tsconfig.json files are ignored.

This is why when you run tsc hero.ts app.ts, your files are compiled.