'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
Solution 1:[1]
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.
Solution 2:[2]
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.
Solution 3:[3]
It looks like your MacOs removed JAVA_HOME variable.
- Download and Install Java JDK (link)
- Find a path to JDK by running
/usr/libexec/java_home -V
Matching Java Virtual Machines (2): 1.8.271.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home 1.8.0_171 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
- Then you need to update you
.zshrcwith
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Hom
- And run build command
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Karolis GrinkeviÄius |
| Solution 2 | Naijia Liu |
| Solution 3 | Azizbek Khamidov |
