dccarmo dccarmo - 1 month ago 12
TypeScript Question

No output with TypeScript 2.0

So previously (TypeScript 1.8) I had this for my tsconfig.json

{
"compilerOptions": {
"target": "es6",
"allowJs": true,
"jsx": "react",
"outDir": "../",
"rootDir": "./",
"sourceMap": true,
"inlineSources": true
},
"filesGlob": [
"typings/**/*.d.ts",
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"."
]
}


And it worked fine. But after updating to TypeScript 2.0 and trying to compile, the compiler gives me no feedback, and there's no output. Has something changed from the previous version that broke my tsconfig? If so, how can I fix it? Thanks

Answer

You should remove the exclude options since it excludes the entire folder. Also use include instead of filesGlob, see the tsconfig.json reference. I normally also define a named output directory instead of dots. In your case I'd set the rootDir to src. So try this tsconfig.json file:

{
  "compilerOptions": {
      "target": "es6",
      "allowJs": true,
      "jsx": "react",
      "outDir": "dist",
      "rootDir": "src",
      "sourceMap": true,
      "inlineSources": true
  },
  "include": [
      "typings/**/*.d.ts",
      "src/**/*.ts",
      "src/**/*.tsx"
  ]
}

The typings system also improved dramatically in Typescript 2.0 and is now entirely included as npm-modules. The typings system has changed a lot but now you can use the familiar syntax:

npm install @types/<package> --save

More info in on the same page.