官术网_书友最值得收藏!

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:

  1. 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.

  1. 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.

主站蜘蛛池模板: 肥乡县| 海口市| 兴安县| 朔州市| 三门峡市| 镇江市| 漳州市| 呼伦贝尔市| 寿宁县| 陈巴尔虎旗| 乌拉特后旗| 普定县| 肥城市| 区。| 南宁市| 进贤县| 中西区| 志丹县| 宁化县| 正安县| 肥西县| 新龙县| 河曲县| 望城县| 乌鲁木齐县| 夏邑县| 昌吉市| 乌兰浩特市| 商丘市| 郁南县| 蒲江县| 什邡市| 罗田县| 桂东县| 连州市| 赣州市| 安义县| 四平市| 巴马| 江孜县| 黄石市|