- 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.
推薦閱讀
- 演進式架構(原書第2版)
- Android和PHP開發最佳實踐(第2版)
- Servlet/JSP深入詳解
- TypeScript圖形渲染實戰:基于WebGL的3D架構與實現
- Apache Kafka Quick Start Guide
- Java高并發核心編程(卷1):NIO、Netty、Redis、ZooKeeper
- 從零開始學C#
- 21天學通C++(第5版)
- MySQL入門很輕松(微課超值版)
- JavaScript程序設計(第2版)
- Building Serverless Architectures
- jQuery從入門到精通(微課精編版)
- SAP Web Dynpro for ABAP開發技術詳解:基礎應用
- Java 9:Building Robust Modular Applications
- ASP.NET jQuery Cookbook(Second Edition)