- 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.
推薦閱讀
- Go Web編程
- Drupal 8 Blueprints
- Java 開發(fā)從入門到精通(第2版)
- INSTANT FreeMarker Starter
- Java游戲服務(wù)器架構(gòu)實戰(zhàn)
- 從零開始:UI圖標(biāo)設(shè)計與制作(第3版)
- Java并發(fā)編程之美
- QPanda量子計算編程
- Python趣味編程與精彩實例
- 大學(xué)計算機(jī)應(yīng)用基礎(chǔ)(Windows 7+Office 2010)(IC3)
- Three.js權(quán)威指南:在網(wǎng)頁上創(chuàng)建3D圖形和動畫的方法與實踐(原書第4版)
- Python Social Media Analytics
- C語言從入門到精通(微視頻精編版)
- Unity與C++網(wǎng)絡(luò)游戲開發(fā)實戰(zhàn):基于VR、AI與分布式架構(gòu)
- 威脅建模:設(shè)計和交付更安全的軟件