- 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.
推薦閱讀
- Vue.js快跑:構建觸手可及的高性能Web應用
- Python零基礎快樂學習之旅(K12實戰訓練)
- 嚴密系統設計:方法、趨勢與挑戰
- Learning Selenium Testing Tools(Third Edition)
- 快速念咒:MySQL入門指南與進階實戰
- 用戶體驗可視化指南
- R用戶Python學習指南:數據科學方法
- 軟件測試綜合技術
- Cocos2d-x Game Development Blueprints
- Natural Language Processing with Python Quick Start Guide
- Spark技術內幕:深入解析Spark內核架構設計與實現原理
- 從零開始學UI設計·基礎篇
- Unity 3D UI Essentials
- HTML5 Game Development by Example:Beginner's Guide(Second Edition)
- Mastering Unity Scripting