2016-12-12 53 views
2

目前,我正在嘗試tsconfig.json中的新擴展功能,該功能允許開發人員擁有基礎tsconfig.json,其他模塊可以擴展/修改。TypeScript 2.1+ tsconfig擴展

它正在工作,但並不如預期。不知何故,獲得這個工作的唯一方法是在父配置和子配置中指定compileroptions.lib。

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(預期)

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

child.tsconfig.json(需要工作)

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

有關此事的一些建議將不勝感激。

乾杯

+1

sourcemap等等,對於我來說似乎也沒什麼用,使用TSC時沒有明顯的錯誤,但VS 2015對錯失模塊和目標抱怨很大。 –

+0

這很奇怪,它適合我們 – Shrike

回答

0

你正在做的一切都是正確的。您的tsconfig.json文件應位於當前項目的根目錄中。仔細檢查您的child.tsconfig.json中是否正確設置了parent.tsconfig.json文件的路徑。