- 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.
推薦閱讀
- 深入理解Android(卷I)
- TensorFlow Lite移動(dòng)端深度學(xué)習(xí)
- Mastering Ember.js
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- iOS開(kāi)發(fā)實(shí)戰(zhàn):從零基礎(chǔ)到App Store上架
- INSTANT Mercurial SCM Essentials How-to
- Python機(jī)器學(xué)習(xí)經(jīng)典實(shí)例
- Learning Zurb Foundation
- 編程菜鳥(niǎo)學(xué)Python數(shù)據(jù)分析
- Java Web開(kāi)發(fā)就該這樣學(xué)
- Spring+Spring MVC+MyBatis從零開(kāi)始學(xué)
- Qlik Sense? Cookbook
- Unity Android Game Development by Example Beginner's Guide
- AutoCAD基礎(chǔ)教程
- Kohana 3.0 Beginner's Guide