- Learn React with TypeScript 3
- Carl Rippon
- 181字
- 2021-06-10 19:16:44
Referencing projects
The first step in setting up TypeScript 3's multiple projects feature is to reference projects using a new field called references in tsconfig.json. This field is an array of objects that specify projects to reference.
In our working example, let's make ProjectA start to understand the Shared project:
- Let's change the tsconfig.json in ProjectA to reference the Shared project:
{
"compilerOptions": {
...
},
"references": [
{ "path": "../shared" }
]
}
If we want the dependent project's generated JavaScript code to be included in the same file as the current project, we can set prepend to true on the dependency .
"references": [
{ "path": "../shared", "prepend": true }
]
We're not going to use prepend in our example though.
- If we compile ProjectA again, a different error is raised:
error TS6306: Referenced project '.../shared' must have setting "composite": true
The error gives a great clue as to what is wrong. We'll resolve this problem with the missing composite setting in the next section.
推薦閱讀
- Java應用開發與實踐
- JavaScript從入門到精通(第3版)
- Python機器學習經典實例
- 青少年Python編程入門
- iOS編程基礎:Swift、Xcode和Cocoa入門指南
- Android程序設計基礎
- Visual C#.NET Web應用程序設計
- Python Data Science Cookbook
- Instant Automapper
- 大學計算機基礎實訓教程
- Learning Cocos2d-JS Game Development
- Java項目驅動開發教程
- Python High Performance(Second Edition)
- Selenium自動化測試完全指南:基于Python
- PHP 程序員面試筆試真題庫