Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript 2.1+ tsconfig extends

Currently, I am trying the new extends feature in the tsconfig.json that allows developers to have a base tsconfig.json, that other modules can extend / modify.

It is working, although not as expected. Somehow, the only way to get this working is to specifiy compileroptions.lib in both parent and child configs.

parent.tsconfig.json

 {
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "lib": [ // Lib compiler options defined!!! 
      "dom",
      "es6"
    ]
  },
  "exclude": [
    "node_modules"
  ],
  "awesomeTypescriptLoaderOptions": {
    "resolveGlobs": true,
    "forkChecker": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

child.tsconfig.json (Expected)

{
  "extends": "../parent.tsconfig.json",
}  

child.tsconfig.json (Required to work)

{
  "extends": "../parent.tsconfig.json",
  "compilerOptions": {
    "lib": [ //Have to specify lib again ==> Double-u-t-f
      "dom",
      "es6"
    ]
  }
}

Some advice on this matter would be appreciated.

Cheers

like image 829
Dennis Jaamann Avatar asked Dec 12 '16 13:12

Dennis Jaamann


People also ask

Can you have multiple Tsconfig?

One tsconfig file is enough for your project but if still for some of technical reasons you want to have more than one for example create 2 different tsconfig files (e.g. tsconfig. a. json and tsconfig.

Can you have multiple Tsconfig json files?

You could use multiple tsconfig files to solve some of those problems, but new ones would appear: There's no built-in up-to-date checking, so you end up always running tsc twice.

What should I put in Tsconfig json?

The tsconfig. json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig. json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.

What does Lib do in Tsconfig?

TypeScript includes a default set of type definitions for built-in JS APIs (like Math ), as well as type definitions for things found in browser environments (like document ).


1 Answers

You are doing everything right. Your tsconfig.json file should be in the root directory of current project. Double check whether the path of parent.tsconfig.json file is correctly set in your child.tsconfig.json.

like image 118
Karolis Grinkevičius Avatar answered Oct 31 '22 03:10

Karolis Grinkevičius