2017-04-21 18 views
1

我試圖讓打字稿編譯時排除某些文件。但它似乎並不想排除它們。打字稿tsconfig排除一些源文件

這裏是我的tsconfig.json

{ 
    "ref": "master", 
    "path": "typings", 
    "compilerOptions": { 
    "module": "amd", 
    "target": "es5", 
    "declaration": true, 
    "sourceMap": true, 
    "outDir": "build/src" 
    }, 
    "exclude": [ 
    "node_modules", 
    "typings/global", 
    "typings/index.d.ts", 
    "./src/subClassA.ts" 
    ], 
    "files": [ 
    "./src/entry.ts" 
    ] 
} 

這似乎是不包括node_modules和分型。但是編譯後的代碼仍然包含subClassA。

我本來期望編譯後的代碼不具有任何從subClassA的代碼,但是它的作用。

+0

是否使用'subClassA'任何地方從你的代碼? – Saravana

回答

1

documentation

包括由文件中引用的任何文件通過「文件」或 「包括」屬性也包括在內。同樣,如果一個文件B.ts是 其它文件A.ts引用,然後B.ts不能排除,除非 的引用文件A.ts在「排除」列表中指定。

如果您./src/entry.ts文件或./src/entry.ts任何依賴使用./src/subClassA.ts某處,然後./src/subClassA.ts不能排除,除非./src/entry.ts被排除在外了。

相關討論:https://github.com/Microsoft/TypeScript/issues/7432

+0

感謝您的鏈接,是一個很好的閱讀。你知道這樣做的任何工作嗎? –