Skip to content

Commit a333a99

Browse files
committed
feat(core): support TypeScript 4.4
Adds support for TypeScript 4.4. High-level overview of the changes made in this PR: * Bumps the various packages to `typescript@4.4.2` and `tslib@2.3.0`. * The `useUnknownInCatchVariables` compiler option has been disabled so that we don't have to cast error objects explicitly everywhere. * TS now passes in a third argument to the `__spreadArray` call inside child class constructors. I had to update a couple of places in the runtime and ngcc to be able to pick up the calls correctly. * TS now generates code like `(0, foo)(arg1, arg2)` for imported function calls. I had to update a few of our tests to account for it. See microsoft/TypeScript#44624. * Our `ngtsc` test setup calls the private `matchFiles` function from TS. I had to update our usage, because a new parameter was added. * There was one place where we were setting the readonly `hasTrailingComma` property. I updated the usage to pass in the value when constructing the object instead. * Some browser types were updated which meant that I had to resolve some trivial type errors. * The downlevel decorators tranform was running into an issue where the Closure synthetic comments were being emitted twice. I've worked around it by recreating the class declaration node instead of cloning it.
1 parent a1633c1 commit a333a99

File tree

55 files changed

+250
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+250
-126
lines changed

aio/aio-builds-setup/dockerbuild/scripts-js/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"shelljs": "^0.8.4",
3434
"source-map-support": "^0.5.19",
3535
"tar-stream": "^2.1.3",
36-
"tslib": "^2.2.0"
36+
"tslib": "^2.3.0"
3737
},
3838
"devDependencies": {
3939
"@types/body-parser": "^1.19.0",
@@ -49,6 +49,6 @@
4949
"supertest": "^4.0.2",
5050
"tslint": "^6.1.3",
5151
"tslint-jasmine-noSkipOrFocus": "^1.0.9",
52-
"typescript": "~4.3.4"
52+
"typescript": "~4.4.2"
5353
}
5454
}

aio/aio-builds-setup/dockerbuild/scripts-js/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"noUnusedParameters": true, /* Report errors on unused parameters. */
3434
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
3535
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
36+
"useUnknownInCatchVariables": false, /* Avoid having to cast error objects inside `catch` clauses. */
3637

3738
/* Module Resolution Options */
3839
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */

aio/aio-builds-setup/dockerbuild/scripts-js/yarn.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -2505,10 +2505,10 @@ tslib@^1.8.1:
25052505
version "1.9.3"
25062506
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
25072507

2508-
tslib@^2.2.0:
2509-
version "2.2.0"
2510-
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
2511-
integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==
2508+
tslib@^2.3.0:
2509+
version "2.3.1"
2510+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
2511+
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
25122512

25132513
tslint-jasmine-noSkipOrFocus@^1.0.9:
25142514
version "1.0.9"
@@ -2563,10 +2563,10 @@ typedarray-to-buffer@^3.1.5:
25632563
dependencies:
25642564
is-typedarray "^1.0.0"
25652565

2566-
typescript@~4.3.4:
2567-
version "4.3.4"
2568-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.4.tgz#3f85b986945bcf31071decdd96cf8bfa65f9dcbc"
2569-
integrity sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==
2566+
typescript@~4.4.2:
2567+
version "4.4.2"
2568+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
2569+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
25702570

25712571
undefsafe@^2.0.2:
25722572
version "2.0.2"

aio/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"@webcomponents/custom-elements": "1.5.0",
103103
"rxjs": "^6.6.7",
104104
"safevalues": "^0.1.8",
105-
"tslib": "^2.2.0",
105+
"tslib": "^2.3.0",
106106
"zone.js": "~0.11.4"
107107
},
108108
"devDependencies": {
@@ -181,7 +181,7 @@
181181
"ts-node": "^10.0.0",
182182
"tsec": "^0.1.5",
183183
"tslint": "~6.1.3",
184-
"typescript": "~4.3.4",
184+
"typescript": "~4.4.2",
185185
"uglify-js": "^3.13.3",
186186
"unist-util-filter": "^2.0.3",
187187
"unist-util-source": "^3.0.0",

aio/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"noFallthroughCasesInSwitch": true,
1111
"noUnusedLocals": true,
1212
"noUnusedParameters": true,
13+
"useUnknownInCatchVariables": false,
1314
"sourceMap": true,
1415
"declaration": false,
1516
"downlevelIteration": true,

aio/yarn.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -12778,7 +12778,7 @@ tslib@^1.10.0, tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0:
1277812778
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
1277912779
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
1278012780

12781-
tslib@^2.0.0, tslib@^2.0.1, tslib@^2.2.0:
12781+
tslib@^2.0.0, tslib@^2.0.1, tslib@^2.2.0, tslib@^2.3.0:
1278212782
version "2.3.1"
1278312783
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
1278412784
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
@@ -12917,10 +12917,10 @@ typescript@~3.2.2:
1291712917
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.4.tgz#c585cb952912263d915b462726ce244ba510ef3d"
1291812918
integrity sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg==
1291912919

12920-
typescript@~4.3.4:
12921-
version "4.3.5"
12922-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
12923-
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
12920+
typescript@~4.4.2:
12921+
version "4.4.2"
12922+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
12923+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
1292412924

1292512925
ua-parser-js@^0.7.28:
1292612926
version "0.7.28"

integration/BUILD.bazel

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ INTEGRATION_TESTS = {
107107
# root @npm//typescript package.
108108
"pinned_npm_packages": ["typescript"],
109109
},
110+
"typings_test_ts44": {
111+
# Special case for `typings_test_ts44` test as we want to pin
112+
# `typescript` at version 4.4.x for that test and not link to the
113+
# root @npm//typescript package.
114+
"pinned_npm_packages": ["typescript"],
115+
},
110116
}
111117

112118
[
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
10+
11+
import * as animations from '@angular/animations';
12+
import * as animationsBrowser from '@angular/animations/browser';
13+
import * as animationsBrowserTesting from '@angular/animations/browser/testing';
14+
import * as common from '@angular/common';
15+
import * as commonHttp from '@angular/common/http';
16+
import * as commonTesting from '@angular/common/testing';
17+
import * as commonHttpTesting from '@angular/common/testing';
18+
import * as compiler from '@angular/compiler';
19+
import * as compilerTesting from '@angular/compiler/testing';
20+
import * as core from '@angular/core';
21+
import * as coreTesting from '@angular/core/testing';
22+
import * as elements from '@angular/elements';
23+
import * as forms from '@angular/forms';
24+
import * as platformBrowser from '@angular/platform-browser';
25+
import * as platformBrowserDynamic from '@angular/platform-browser-dynamic';
26+
import * as platformBrowserDynamicTesting from '@angular/platform-browser-dynamic/testing';
27+
import * as platformBrowserAnimations from '@angular/platform-browser/animations';
28+
import * as platformBrowserTesting from '@angular/platform-browser/testing';
29+
import * as platformServer from '@angular/platform-server';
30+
import * as platformServerInit from '@angular/platform-server/init';
31+
import * as platformServerTesting from '@angular/platform-server/testing';
32+
import * as router from '@angular/router';
33+
import * as routerTesting from '@angular/router/testing';
34+
import * as routerUpgrade from '@angular/router/upgrade';
35+
import * as serviceWorker from '@angular/service-worker';
36+
import * as upgrade from '@angular/upgrade';
37+
import * as upgradeStatic from '@angular/upgrade/static';
38+
import * as upgradeTesting from '@angular/upgrade/static/testing';
39+
40+
export default {
41+
animations,
42+
animationsBrowser,
43+
animationsBrowserTesting,
44+
common,
45+
commonTesting,
46+
commonHttp,
47+
commonHttpTesting,
48+
compiler,
49+
compilerTesting,
50+
core,
51+
coreTesting,
52+
elements,
53+
forms,
54+
platformBrowser,
55+
platformBrowserTesting,
56+
platformBrowserDynamic,
57+
platformBrowserDynamicTesting,
58+
platformBrowserAnimations,
59+
platformServer,
60+
platformServerInit,
61+
platformServerTesting,
62+
router,
63+
routerTesting,
64+
routerUpgrade,
65+
serviceWorker,
66+
upgrade,
67+
upgradeStatic,
68+
upgradeTesting,
69+
};
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "angular-integration",
3+
"description": "Assert that users with TypeScript 4.4 can type-check an Angular application",
4+
"version": "0.0.0",
5+
"license": "MIT",
6+
"dependencies": {
7+
"@angular/animations": "file:../../dist/packages-dist/animations",
8+
"@angular/common": "file:../../dist/packages-dist/common",
9+
"@angular/compiler": "file:../../dist/packages-dist/compiler",
10+
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
11+
"@angular/core": "file:../../dist/packages-dist/core",
12+
"@angular/elements": "file:../../dist/packages-dist/elements",
13+
"@angular/forms": "file:../../dist/packages-dist/forms",
14+
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
15+
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
16+
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
17+
"@angular/router": "file:../../dist/packages-dist/router",
18+
"@angular/service-worker": "file:../../dist/packages-dist/service-worker",
19+
"@angular/upgrade": "file:../../dist/packages-dist/upgrade",
20+
"@types/jasmine": "file:../../node_modules/@types/jasmine",
21+
"rxjs": "file:../../node_modules/rxjs",
22+
"typescript": "4.4.2",
23+
"zone.js": "file:../../dist/zone.js-dist/archive/zone.js.tgz"
24+
},
25+
"scripts": {
26+
"test": "tsc"
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"forceConsistentCasingInFileNames": true,
4+
"strict": true,
5+
"noImplicitReturns": true,
6+
"noFallthroughCasesInSwitch": true,
7+
"experimentalDecorators": true,
8+
"module": "commonjs",
9+
"moduleResolution": "node",
10+
"outDir": "./dist/out-tsc",
11+
"rootDir": ".",
12+
"target": "es5",
13+
"lib": [
14+
"es5",
15+
"dom",
16+
"es2015.collection",
17+
"es2015.iterable",
18+
"es2015.promise"
19+
],
20+
"types": [],
21+
},
22+
"files": [
23+
"include-all.ts",
24+
"node_modules/@types/jasmine/index.d.ts"
25+
]
26+
}

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@
147147
"terser": "^4.4.0",
148148
"tmp": "0.2.1",
149149
"tsickle": "0.38.1",
150-
"tslib": "^2.2.0",
150+
"tslib": "^2.3.0",
151151
"tslint": "6.1.3",
152-
"typescript": "~4.3.4",
152+
"typescript": "~4.4.2",
153153
"xhr2": "0.2.1",
154154
"yargs": "^17.0.0"
155155
},
@@ -191,6 +191,7 @@
191191
"// 4": "Overwrite graceful-fs to a version that does not rely on the 'natives' package. This fixes gulp for >= 10.13, more information: #28213",
192192
"// 5": "Ensure a single version of webdriver-manager so it is hoisted as the integration tests depend on it being found at ../../node_modules/webdriver-manager",
193193
"// 6": "Ensure that `@babel/*` packages match the below versions to avoid conflicts with `types/babel__*`",
194+
"// 7": "TypeScript has to be resolved to 4.4 temporarily until @microsoft/api-extractor is updated",
194195
"resolutions": {
195196
"**/graceful-fs": "4.2.8",
196197
"**/webdriver-manager": "12.1.8",
@@ -200,6 +201,7 @@
200201
"@babel/preset-env": "7.10.2",
201202
"@babel/template": "7.8.6",
202203
"@babel/traverse": "7.8.6",
203-
"@babel/types": "7.8.6"
204+
"@babel/types": "7.8.6",
205+
"typescript": "4.4.2"
204206
}
205207
}

packages/animations/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"node": "^12.14.1 || >=14.0.0"
99
},
1010
"dependencies": {
11-
"tslib": "^2.2.0"
11+
"tslib": "^2.3.0"
1212
},
1313
"peerDependencies": {
1414
"@angular/core": "0.0.0-PLACEHOLDER"

packages/bazel/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
"@microsoft/api-extractor": "7.18.7",
2727
"shelljs": "0.8.4",
2828
"tsickle": "^0.38.0",
29-
"tslib": "^2.2.0"
29+
"tslib": "^2.3.0"
3030
},
3131
"peerDependencies": {
3232
"@angular/compiler-cli": "0.0.0-PLACEHOLDER",
3333
"@bazel/typescript": ">=1.0.0",
3434
"terser": "^4.3.1",
35-
"typescript": ">=4.2.3 <4.4",
35+
"typescript": ">=4.2.3 <4.5",
3636
"rollup": ">=1.20.0",
3737
"rollup-plugin-commonjs": ">=9.0.0",
3838
"rollup-plugin-node-resolve": ">=4.2.0",

packages/benchpress/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "Benchpress - a framework for e2e performance tests",
55
"main": "index.js",
66
"typings": "./index.d.ts",
7-
"strictNullChecks": true,
87
"dependencies": {
98
"@angular/core": "^12.0.0",
109
"reflect-metadata": "^0.1.13"

packages/common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"locales": "locales",
1111
"dependencies": {
12-
"tslib": "^2.2.0"
12+
"tslib": "^2.3.0"
1313
},
1414
"peerDependencies": {
1515
"@angular/core": "0.0.0-PLACEHOLDER",

packages/compiler-cli/ngcc/src/host/esm5_host.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
573573
*
574574
* 1. `__spread(arguments)`
575575
* 2. `__spreadArray([], __read(arguments))`
576+
* 3. `__spreadArray([], __read(arguments), false)`
576577
*
577578
* The tslib helpers may have been emitted inline as in the above example, or they may be read
578579
* from a namespace import.
@@ -587,8 +588,8 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
587588
// `__spread(arguments)`
588589
return call.args.length === 1 && isArgumentsIdentifier(call.args[0]);
589590
} else if (call.helper === KnownDeclaration.TsHelperSpreadArray) {
590-
// `__spreadArray([], __read(arguments))`
591-
if (call.args.length !== 2) {
591+
// `__spreadArray([], __read(arguments), false)`
592+
if (call.args.length !== 2 && call.args.length !== 3) {
592593
return false;
593594
}
594595

packages/compiler-cli/ngcc/test/integration/ngcc_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ runInEachFileSystem(() => {
381381

382382
const jsContents = fs.readFile(_(`/node_modules/test-package/esm5/src/index.js`));
383383
// Verify that the ES5 bundle does contain the expected downleveling syntax.
384-
expect(jsContents).toContain('__spreadArray([], __read(arguments))');
384+
expect(jsContents).toContain('__spreadArray([], __read(arguments), false)');
385385
expect(jsContents)
386386
.toContain(
387387
'var ɵSubClass_BaseFactory; return function SubClass_Factory(t) { return (ɵSubClass_BaseFactory || (ɵSubClass_BaseFactory = ɵngcc0.ɵɵgetInheritedFactory(SubClass)))(t || SubClass); };');
@@ -420,7 +420,7 @@ runInEachFileSystem(() => {
420420

421421
const jsContents = fs.readFile(_(`/node_modules/test-package/esm5/src/index.js`));
422422
// Verify that the ES5 bundle does contain the expected downleveling syntax.
423-
expect(jsContents).toContain('__spreadArray([], __read(arguments))');
423+
expect(jsContents).toContain('__spreadArray([], __read(arguments), false)');
424424
expect(jsContents)
425425
.toContain(
426426
'var ɵSubClass_BaseFactory; return function SubClass_Factory(t) { return (ɵSubClass_BaseFactory || (ɵSubClass_BaseFactory = ɵngcc0.ɵɵgetInheritedFactory(SubClass)))(t || SubClass); };');

packages/compiler-cli/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"semver": "^7.0.0",
2424
"source-map": "^0.6.1",
2525
"sourcemap-codec": "^1.4.8",
26-
"tslib": "^2.2.0",
26+
"tslib": "^2.3.0",
2727
"yargs": "^17.0.0"
2828
},
2929
"peerDependencies": {
3030
"@angular/compiler": "0.0.0-PLACEHOLDER",
31-
"typescript": ">=4.2.3 <4.4"
31+
"typescript": ">=4.2.3 <4.5"
3232
},
3333
"repository": {
3434
"type": "git",

0 commit comments

Comments
 (0)