19

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

nullptr
  • 3,701
  • 2
  • 16
  • 40
Dennis Jaamann
  • 3,547
  • 2
  • 23
  • 42
  • 3
    sourcemap, etc., also don't seem to work for me, no apparent error when using tsc, but VS 2015 complained mightily about missing module and target, too. – Jon B Jan 04 '17 at 21:13
  • 1
    that's strange, it works for us – Shrike Mar 24 '17 at 10:59
  • 1
    I've had a look at the code (https://github.com/Microsoft/TypeScript/blob/master/src/compiler/commandLineParser.ts#L1982) as we've had the same problem. It looks like it should work because it copies anything that isn't in the tsconfig compilerOptions (determined by hasOwnProperty) from the inherited options. – Richard Corfield Sep 11 '18 at 10:44

2 Answers2

0

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.

0

In my case, I run tsc command in the parent folder which just use the tsconfig.json from parent folder but not the one in child folders.

It works when running tsc command in the child folders, or running tsc -p child_folder_name from the parent folder also works.

Naijia Liu
  • 299
  • 3
  • 5