Skip to content

Commit 0205e52

Browse files
committed
Fix lint errors
1 parent 8ad3b7b commit 0205e52

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

pages/Project References.md

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ We're also introducing a new mode for `tsc`, the `--build` flag, that works hand
88

99
Let's look at a fairly normal program and see how project references can help us better organize it.
1010
Imagine you have a project with two modules, `converter` and `units`, and a corresponding test file for each:
11-
```
11+
12+
```shell
1213
/src/converter.ts
1314
/src/units.ts
1415
/test/converter-tests.ts
@@ -17,29 +18,33 @@ Imagine you have a project with two modules, `converter` and `units`, and a corr
1718
```
1819

1920
The test files import the implementation files and do some testing:
20-
```
21+
22+
```ts
2123
// converter-tests.ts
2224
import * as converter from "../converter";
2325

2426
assert.areEqual(converter.celsiusToFahrenheit(0), 32);
2527
```
2628

2729
Previously, this structure was rather awkward to work with if you used a single tsconfig file:
28-
* It was possible for the implementation files to import the test files
29-
* It wasn't possible to build `test` and `src` at the same time without having `src` appear in the output folder name, which you probably don't want
30-
* Changing just the *internals* in the implementation files required *typechecking* the tests again, even though this wouldn't ever cause new errors
31-
* Changing just the tests required typechecking the implementation again, even if nothing changed
30+
31+
* It was possible for the implementation files to import the test files
32+
* It wasn't possible to build `test` and `src` at the same time without having `src` appear in the output folder name, which you probably don't want
33+
* Changing just the *internals* in the implementation files required *typechecking* the tests again, even though this wouldn't ever cause new errors
34+
* Changing just the tests required typechecking the implementation again, even if nothing changed
3235

3336
You could use multiple tsconfig files to solve *some* of those problems, but new ones would appear:
34-
* There's no built-in up-to-date checking, so you end up always running `tsc` twice
35-
* Invoking `tsc` twice incurs more startup time overhead
36-
* `tsc -w` can't run on multiple config files at once
37+
38+
* There's no built-in up-to-date checking, so you end up always running `tsc` twice
39+
* Invoking `tsc` twice incurs more startup time overhead
40+
* `tsc -w` can't run on multiple config files at once
3741

3842
Project references can solve all of these problems and more.
3943

4044
# What is a Project Reference?
4145

4246
`tsconfig.json` files have a new top-level property, `references`. It's an array of objects that specifies projects to reference:
47+
4348
```js
4449
{
4550
"compilerOptions": {
@@ -54,9 +59,10 @@ Project references can solve all of these problems and more.
5459
The `path` property of each reference can point to a directory containing a `tsconfig.json` file, or to the config file itself (which may have any name).
5560

5661
When you reference a project, new things happen:
57-
* Importing modules from a referenced project will instead load its *output* declaration file (`.d.ts`)
58-
* If the referenced project produces an `outFile`, the output file `.d.ts` file's declarations will be visible in this project
59-
* Build mode (see below) will automatically build the referenced project if needed
62+
63+
* Importing modules from a referenced project will instead load its *output* declaration file (`.d.ts`)
64+
* If the referenced project produces an `outFile`, the output file `.d.ts` file's declarations will be visible in this project
65+
* Build mode (see below) will automatically build the referenced project if needed
6066

6167
By separating into multiple projects, you can greatly improve the speed of typechecking and compiling, reduce memory usage when using an editor, and improve enforcement of the logical groupings of your program.
6268

@@ -65,9 +71,10 @@ By separating into multiple projects, you can greatly improve the speed of typec
6571
Referenced projects must have the new `composite` setting enabled.
6672
This setting is needed to ensure TypeScript can quickly determine where to find the outputs of the referenced project.
6773
Enabling the `composite` flag changes a few things:
68-
* The `rootDir` setting, if not explicitly set, defaults to the directory containing the `tsconfig` file
69-
* All implementation files must be matched by an `include` pattern or listed in the `files` array. If this constraint is violated, `tsc` will inform you which files weren't specified
70-
* `declaration` must be turned on
74+
75+
* The `rootDir` setting, if not explicitly set, defaults to the directory containing the `tsconfig` file
76+
* All implementation files must be matched by an `include` pattern or listed in the `files` array. If this constraint is violated, `tsc` will inform you which files weren't specified
77+
* `declaration` must be turned on
7178

7279
# `declarationMaps`
7380

@@ -77,6 +84,7 @@ If you enable `--declarationMap`, you'll be able to use editor features like "Go
7784
# `prepend` with `outFile`
7885

7986
You can also enable prepending the output of a dependency using the `prepend` option in a reference:
87+
8088
```js
8189
"references": [
8290
{ "path": "../utils", "prepend": true }
@@ -88,15 +96,17 @@ This works for both `.js` files and `.d.ts` files, and source map files will als
8896

8997
`tsc` will only ever use existing files on disk to do this process, so it's possible to create a project where a correct output file can't be generated because some project's output would be present more than once in the resulting file.
9098
For example:
91-
```
99+
100+
```txt
92101
A
93-
^ ^
102+
^ ^
94103
/ \
95104
B C
96105
^ ^
97106
\ /
98107
D
99108
```
109+
100110
It's important in this situation to not prepend at each reference, because you'll end up with two copies of `A` in the output of `D` - this can lead to unexpected results.
101111

102112
# Caveats for Project References
@@ -116,9 +126,10 @@ In 3.0 you can use the `--build` flag with `tsc`.
116126
This is effectively a new entry point for `tsc` that behaves more like a build orchestrator than a simple compiler.
117127

118128
Running `tsc --build` (`tsc -b` for short) will do the following:
119-
* Find all referenced projects
120-
* Detect if they are up-to-date
121-
* Build out-of-date projects in the correct order
129+
130+
* Find all referenced projects
131+
* Detect if they are up-to-date
132+
* Build out-of-date projects in the correct order
122133

123134
You can provide `tsc -b` with multiple config file paths (e.g. `tsc -b src test`).
124135
Just like `tsc -p`, specifying the config file name itself is unnecessary if it's named `tsconfig.json`.
@@ -127,7 +138,7 @@ Just like `tsc -p`, specifying the config file name itself is unnecessary if it'
127138

128139
You can specify any number of config files:
129140

130-
```
141+
```shell
131142
> tsc -b # Build the tsconfig.json in the current directory
132143
> tsc -b src # Build src/tsconfig.json
133144
> tsc -b foo/release.tsconfig.json bar # Build foo/release.tsconfig.json and bar/tsconfig.json
@@ -136,11 +147,12 @@ You can specify any number of config files:
136147
Don't worry about ordering the files you pass on the commandline - `tsc` will re-order them if needed so that dependencies are always built first.
137148

138149
There are also some flags specific to `tsc -b`:
139-
* `--verbose`: Prints out verbose logging to explain what's going on (may be combined with any other flag)
140-
* `--dry`: Shows what would be done but doesn't actually build anything
141-
* `--clean`: Deletes the outputs of the specified projects (may be combined with `--dry`)
142-
* `--force`: Act as if all projects are out of date
143-
* `--watch`: Watch mode (may not be combined with any flag except `--verbose`)
150+
151+
* `--verbose`: Prints out verbose logging to explain what's going on (may be combined with any other flag)
152+
* `--dry`: Shows what would be done but doesn't actually build anything
153+
* `--clean`: Deletes the outputs of the specified projects (may be combined with `--dry`)
154+
* `--force`: Act as if all projects are out of date
155+
* `--watch`: Watch mode (may not be combined with any flag except `--verbose`)
144156

145157
# Caveats
146158

@@ -153,9 +165,11 @@ If you check in any build outputs (`.js`, `.d.ts`, `.d.ts.map`, etc.), you may n
153165
# MSBuild
154166

155167
If you have an msbuild project, you can turn enable build mode by adding
156-
```XML
168+
169+
```xml
157170
<TypeScriptBuildMode>true</TypeScriptBuildMode>
158171
```
172+
159173
to your proj file. This will enable automatic incremental build as well as cleaning.
160174

161175
Note that as with `tsconfig.json` / `-p`, existing TypeScript project properties will not be respected - all settings should be managed using your tsconfig file.

pages/release notes/TypeScript 3.0.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Project Refrences
22

3-
TypeScript 3.0 introduces a new concept of project references. Project references allow TypeScript projects to depend on other TypeScript projects - specifically, allowing `tsconfig.json` files to reference other `tsconfig.json` files. Specifying these dependencies makes it easier to split your code into smaller projects, since it gives TypeScript (and tools around it) a way to understand build ordering and output structure.
3+
TypeScript 3.0 introduces a new concept of project references. Project references allow TypeScript projects to depend on other TypeScript projects - specifically, allowing `tsconfig.json` files to reference other `tsconfig.json` files. Specifying these dependencies makes it easier to split your code into smaller projects, since it gives TypeScript (and tools around it) a way to understand build ordering and output structure.
44

55
TypeScript 3.0 introduces also introducing a new mode for tsc, the `--build` flag, that works hand-in-hand with project references to enable faster TypeScript builds.
66

@@ -280,8 +280,6 @@ class C1 {
280280
}
281281
```
282282

283-
284-
285283
# Support for `defaultProps` in JSX
286284

287285
TypeScript 2.9 and earlier didn’t leverage [React `defaultProps`](https://reactjs.org/docs/typechecking-with-proptypes.html#default-prop-values) declarations inside JSX components.

0 commit comments

Comments
 (0)