Skip to content

Commit 48853be

Browse files
alan-agius4pkozlowski-opensource
authored andcommitted
docs: update typescript configuration (angular#47842)
This commits update the TypeScript configuration for the updated version 15 release. PR Close angular#47842
1 parent 3210bea commit 48853be

File tree

3 files changed

+32
-48
lines changed

3 files changed

+32
-48
lines changed
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
// This tsconfig is used in the TypeScript
2-
// configuration guide (../guide/typescript-configuration.md)
2+
// configuration guide (../guide/typescript-configuration.md)
33
// to display the latest default configuration
44
// Note: Update with every major release to the latest default
55
// #docregion
6+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
67
{
78
"compileOnSave": false,
89
"compilerOptions": {
910
"baseUrl": "./",
10-
"outDir": "./dist/out-tsc",
11+
"forceConsistentCasingInFileNames": true,
12+
"strict": true,
13+
"noImplicitOverride": true,
14+
"noPropertyAccessFromIndexSignature": true,
15+
"noImplicitReturns": true,
16+
"noFallthroughCasesInSwitch": true,
1117
"sourceMap": true,
1218
"declaration": false,
13-
"module": "esnext",
14-
"moduleResolution": "node",
19+
"downlevelIteration": true,
1520
"experimentalDecorators": true,
21+
"moduleResolution": "node",
1622
"importHelpers": true,
17-
"target": "es2015",
18-
"typeRoots": [
19-
"node_modules/@types"
20-
],
21-
// #docregion lib
23+
"target": "ES2022",
24+
"module": "ES2022",
25+
"useDefineForClassFields": false,
2226
"lib": [
23-
"es2018",
27+
"ES2022",
2428
"dom"
2529
]
26-
// #enddocregion lib
30+
},
31+
"angularCompilerOptions": {
32+
"enableI18nLegacyMessageIdFormat": false,
33+
"strictInjectionParameters": true,
34+
"strictInputAccessModifiers": true,
35+
"strictTemplates": true
2736
}
2837
}

aio/content/guide/build.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ To disable these warnings, add the CommonJS module name to `allowedCommonJsDepen
305305

306306
The Angular CLI uses [Browserslist](https://github.com/browserslist/browserslist) to ensure compatibility with different browser versions. [Autoprefixer](https://github.com/postcss/autoprefixer) is used for CSS vendor prefixing and [@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env) for JavaScript syntax transformations.
307307

308-
Internally, the Angular CLI uses the below `browserslist` configuration which matches the [browsers that are supported by Angular](guide/browser-support).
308+
Internally, the Angular CLI uses the below `browserslist` configuration which matches the [browsers that are supported](guide/browser-support) by Angular.
309309

310310
<code-example format="none" language="text">
311311
last 1 Chrome version
@@ -317,9 +317,6 @@ Internally, the Angular CLI uses the below `browserslist` configuration which ma
317317
</code-example>
318318

319319

320-
The CLI uses [Autoprefixer](https://github.com/postcss/autoprefixer) to ensure compatibility with different browser and browser versions.
321-
You might find it necessary to target specific browsers or exclude certain browser versions from your build.
322-
323320
To override the internal configuration, add a new file named `.browserslistrc`, to the project directory, that specifies the browsers you want to support:
324321

325322
<code-example format="none" language="text">
@@ -330,7 +327,9 @@ To override the internal configuration, add a new file named `.browserslistrc`,
330327
See the [browserslist repository](https://github.com/browserslist/browserslist) for more examples of how to target specific browsers and versions.
331328

332329
<div class="alert is-helpful">
330+
333331
Use [browsersl.ist](https://browsersl.ist) to display compatible browsers for a `browserslist` query.
332+
334333
</div>
335334

336335
<a id="proxy"></a>

aio/content/guide/typescript-configuration.md

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,14 @@ For more information, see the [Configuration inheritance with extends](https://w
3232

3333
<div class="alert is-helpful">
3434

35-
For more information TypeScript configuration files, see the official [TypeScript wiki](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
35+
For more information TypeScript configuration files, see the official [TypeScript handbook](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
3636
For details about configuration inheritance, see the [Configuration inheritance with extends](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#configuration-inheritance-with-extends) section.
3737

3838
</div>
3939

4040
The initial `tsconfig.json` for an Angular workspace typically looks like the following example.
4141

42-
<code-example lang="json" header="tsconfig.json" linenums="false">
43-
{
44-
"compileOnSave": false,
45-
"compilerOptions": {
46-
"baseUrl": "./",
47-
"outDir": "./dist/out-tsc",
48-
"sourceMap": true,
49-
"declaration": false,
50-
"downlevelIteration": true,
51-
"experimentalDecorators": true,
52-
"moduleResolution": "node",
53-
"importHelpers": true,
54-
"target": "es2015",
55-
"module": "es2020",
56-
"lib": [
57-
"es2018",
58-
"dom"
59-
]
60-
}
61-
}
62-
</code-example>
42+
<code-example header="tsconfig.json" path="getting-started/tsconfig.0.json"></code-example>
6343

6444
<a id="noImplicitAny"></a>
6545

@@ -116,17 +96,12 @@ Angular packages include them already.
11696

11797
</div>
11898

119-
### `lib.d.ts`
120-
121-
TypeScript includes a special declaration file called `lib.d.ts`.
122-
This file contains the ambient declarations for various common JavaScript constructs present in JavaScript runtimes and the DOM.
123-
124-
Based on the `--target`, TypeScript adds *additional* ambient declarations like `Promise` if the target is `es6`.
99+
### `lib`
125100

126-
By default, the target is `es2015`.
127-
If you are targeting `es5`, you still have newer type declarations due to the list of declaration files included:
101+
TypeScript includes a default set of declaration files.
102+
These files contain the ambient declarations for various common JavaScript constructs present in JavaScript runtimes and the DOM.
128103

129-
<code-example header="tsconfig.json (lib excerpt)" path="getting-started/tsconfig.0.json" region="lib"></code-example>
104+
For more information, see [lib](https://www.typescriptlang.org/tsconfig#lib) in the TypeScript guide.
130105

131106
### Installable typings files
132107

@@ -148,12 +123,13 @@ For instance, to install typings for `chai` you run `npm install @types/chai --s
148123

149124
### `target`
150125

151-
By default, the target is `es2020`, which is supported in modern browsers.
126+
By default, the target is `ES2022`. To control ECMA syntax use the [Browserslist](https://github.com/browserslist/browserslist) configuration file.
127+
For more information, see the [configuring browser compatibility](/guide/build#configuring-browser-compatibility) guide.
152128

153129
<!-- links -->
154130

155131
<!-- external links -->
156132

157133
<!-- end links -->
158134

159-
@reviewed 2022-02-28
135+
@reviewed 2022-10-24

0 commit comments

Comments
 (0)