Skip to content

Commit d5d706e

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 `[email protected]` and `[email protected]`. * The error object in `catch` clauses is now typed as `unknown` which caused a lot of compilation errors. I've resolved it by casting either to `Error` or `any` depending on the use case. Note that I've been using `as` casts, rather than typing the object directly, because TS only allows for `any` or `unknown` to be used in the `catch` clause parameters. * 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. * There seems to be a bug in `addSyntheticLeadingComment` that was causing the comments to be duplicated. I've updated one of our tests, because I assume that this won't be a problem for Closure.
1 parent 95cfd0b commit d5d706e

File tree

124 files changed

+419
-263
lines changed

Some content is hidden

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

124 files changed

+419
-263
lines changed

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/lib/common/circle-ci-api.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@ export interface BuildInfo {
2222
username: string;
2323
build_num: number;
2424
has_artifacts: boolean;
25-
outcome: string; // e.g. 'success'
26-
vcs_revision: string; // HEAD SHA
25+
outcome: string; // e.g. 'success'
26+
vcs_revision: string; // HEAD SHA
2727
// there are other fields but they are not used in this code
2828
}
2929

3030
/**
3131
* A Helper that can interact with the CircleCI API.
3232
*/
3333
export class CircleCiApi {
34-
3534
private tokenParam = `circle-token=${this.circleCiToken}`;
3635

3736
/**
3837
* Construct a helper that can interact with the CircleCI REST API.
39-
* @param githubOrg The Github organisation whose repos we want to access in CircleCI (e.g. angular).
38+
* @param githubOrg The Github organisation whose repos we want to access in CircleCI (e.g.
39+
* angular).
4040
* @param githubRepo The Github repo whose builds we want to access in CircleCI (e.g. angular).
4141
* @param circleCiToken The CircleCI API access token (secret).
4242
*/
4343
constructor(
44-
private githubOrg: string,
45-
private githubRepo: string,
46-
private circleCiToken: string,
44+
private githubOrg: string,
45+
private githubRepo: string,
46+
private circleCiToken: string,
4747
) {
4848
assertNotMissingOrEmpty('githubOrg', githubOrg);
4949
assertNotMissingOrEmpty('githubRepo', githubRepo);
@@ -64,7 +64,7 @@ export class CircleCiApi {
6464
}
6565
return response.json();
6666
} catch (error) {
67-
throw new Error(`CircleCI build info request failed (${error.message})`);
67+
throw new Error(`CircleCI build info request failed (${(error as Error).message})`);
6868
}
6969
}
7070

@@ -84,7 +84,7 @@ export class CircleCiApi {
8484
}
8585
return artifact.url;
8686
} catch (error) {
87-
throw new Error(`CircleCI artifact URL request failed (${error.message})`);
87+
throw new Error(`CircleCI artifact URL request failed (${(error as Error).message})`);
8888
}
8989
}
9090
}

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/lib/common/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const getEnvVar = (name: string, isOptional = false): string => {
6666
try {
6767
throw new Error(`ERROR: Missing required environment variable '${name}'!`);
6868
} catch (error) {
69-
console.error(error.stack);
69+
console.error((error as Error).stack);
7070
process.exit(1);
7171
}
7272
}

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/lib/preview-server/build-retriever.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class BuildRetriever {
6565
await promisify(fs.writeFile)(outPath, buffer);
6666
}
6767
return outPath;
68-
} catch (error) {
68+
} catch (error: any) {
6969
this.logger.warn(error);
7070
const status = (error.type === 'max-size') ? 413 : 500;
7171
throw new PreviewServerError(status, `CircleCI artifact download failed (${error.message || error})`);

Diff for: 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
}

Diff for: aio/aio-builds-setup/dockerbuild/scripts-js/test/preview-server/utils.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('preview-server/utils', () => {
3737
originalUrl: 'some.domain.com/path',
3838
} as express.Request;
3939
throwRequestError(505, 'ERROR MESSAGE', request);
40-
} catch (error) {
40+
} catch (error: any) {
4141
caught = true;
4242
expect(error).toBeInstanceOf(PreviewServerError);
4343
expect(error.status).toEqual(505);

Diff for: 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"

Diff for: aio/content/examples/cli-builder/src/my-builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function copyFileBuilder(
2929
// #docregion builder
3030
return {
3131
success: false,
32-
error: err.message,
32+
error: (err as Error).message,
3333
};
3434
}
3535

Diff for: aio/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"@angular/service-worker": "12.1.1",
101101
"@webcomponents/custom-elements": "1.5.0",
102102
"rxjs": "^6.6.7",
103-
"tslib": "^2.2.0",
103+
"tslib": "^2.3.0",
104104
"zone.js": "~0.11.4"
105105
},
106106
"devDependencies": {
@@ -177,7 +177,7 @@
177177
"tree-kill": "^1.1.0",
178178
"ts-node": "^10.0.0",
179179
"tslint": "~6.1.3",
180-
"typescript": "~4.3.4",
180+
"typescript": "~4.4.2",
181181
"uglify-js": "^3.13.3",
182182
"unist-util-filter": "^2.0.3",
183183
"unist-util-source": "^3.0.0",

Diff for: aio/src/app/layout/doc-viewer/doc-viewer.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ async function printSwDebugInfo(): Promise<void> {
294294
}
295295
console.log(await res.text());
296296
} catch (err) {
297-
console.log(`Failed to retrieve debug info from '/ngsw/state': ${err.message || err}`);
297+
console.log('Failed to retrieve debug info from \'/ngsw/state\': ' +
298+
(err as Error).message || err);
298299
}
299300
}
300301

Diff for: aio/tools/examples/shared/boilerplate/cli-ajs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"angular-in-memory-web-api": "~0.11.0",
2727
"angular-route": "1.8.0",
2828
"rxjs": "~6.6.0",
29-
"tslib": "^2.2.0",
29+
"tslib": "^2.3.0",
3030
"zone.js": "~0.11.4"
3131
},
3232
"devDependencies": {
@@ -49,6 +49,6 @@
4949
"protractor": "~7.0.0",
5050
"ts-node": "~10.1.0",
5151
"tslint": "~6.1.0",
52-
"typescript": "~4.3.2"
52+
"typescript": "~4.4.2"
5353
}
5454
}

Diff for: aio/tools/examples/shared/boilerplate/cli/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@angular/router": "~12.1.0-",
2525
"angular-in-memory-web-api": "~0.11.0",
2626
"rxjs": "~6.6.0",
27-
"tslib": "^2.2.0",
27+
"tslib": "^2.3.0",
2828
"zone.js": "~0.11.4"
2929
},
3030
"devDependencies": {
@@ -45,6 +45,6 @@
4545
"protractor": "~7.0.0",
4646
"ts-node": "~10.1.0",
4747
"tslint": "~6.1.0",
48-
"typescript": "~4.3.2"
48+
"typescript": "~4.4.2"
4949
}
5050
}

Diff for: aio/tools/examples/shared/boilerplate/elements/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@webcomponents/custom-elements": "^1.4.2",
2727
"angular-in-memory-web-api": "~0.11.0",
2828
"rxjs": "~6.6.0",
29-
"tslib": "^2.2.0",
29+
"tslib": "^2.3.0",
3030
"zone.js": "~0.11.4"
3131
},
3232
"devDependencies": {
@@ -47,6 +47,6 @@
4747
"protractor": "~7.0.0",
4848
"ts-node": "~10.1.0",
4949
"tslint": "~6.1.0",
50-
"typescript": "~4.3.2"
50+
"typescript": "~4.4.2"
5151
}
5252
}

Diff for: aio/tools/examples/shared/boilerplate/i18n/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@angular/router": "~12.1.0-",
2929
"angular-in-memory-web-api": "~0.11.0",
3030
"rxjs": "~6.6.0",
31-
"tslib": "^2.2.0",
31+
"tslib": "^2.3.0",
3232
"zone.js": "~0.11.4"
3333
},
3434
"devDependencies": {
@@ -49,6 +49,6 @@
4949
"protractor": "~7.0.0",
5050
"ts-node": "~10.1.0",
5151
"tslint": "~6.1.0",
52-
"typescript": "~4.3.2"
52+
"typescript": "~4.4.2"
5353
}
5454
}

Diff for: aio/tools/examples/shared/boilerplate/service-worker/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@angular/service-worker": "~12.1.0-",
2626
"angular-in-memory-web-api": "~0.11.0",
2727
"rxjs": "~6.6.0",
28-
"tslib": "^2.2.0",
28+
"tslib": "^2.3.0",
2929
"zone.js": "~0.11.4"
3030
},
3131
"devDependencies": {
@@ -46,6 +46,6 @@
4646
"protractor": "~7.0.0",
4747
"ts-node": "~10.1.0",
4848
"tslint": "~6.1.0",
49-
"typescript": "~4.3.2"
49+
"typescript": "~4.4.2"
5050
}
5151
}

Diff for: aio/tools/examples/shared/boilerplate/systemjs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@angular/upgrade": "~12.1.0-",
3838
"core-js": "^2.5.4",
3939
"rxjs": "~6.6.0",
40-
"tslib": "^2.2.0",
40+
"tslib": "^2.3.0",
4141
"zone.js": "~0.11.4"
4242
},
4343
"devDependencies": {
@@ -63,6 +63,6 @@
6363
"rollup-plugin-node-resolve": "^4.0.0",
6464
"rollup-plugin-terser": "^5.3.0",
6565
"tslint": "~6.1.0",
66-
"typescript": "~4.3.2"
66+
"typescript": "~4.4.2"
6767
}
6868
}

Diff for: aio/tools/examples/shared/boilerplate/universal/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"angular-in-memory-web-api": "~0.11.0",
3232
"express": "^4.15.2",
3333
"rxjs": "~6.6.0",
34-
"tslib": "^2.2.0",
34+
"tslib": "^2.3.0",
3535
"zone.js": "~0.11.4"
3636
},
3737
"devDependencies": {
@@ -54,6 +54,6 @@
5454
"protractor": "~7.0.0",
5555
"ts-node": "~10.1.0",
5656
"tslint": "~6.1.0",
57-
"typescript": "~4.3.2"
57+
"typescript": "~4.4.2"
5858
}
5959
}

Diff for: aio/tools/examples/shared/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"express": "^4.15.2",
4444
"rxjs": "~6.6.0",
4545
"systemjs": "0.19.39",
46-
"tslib": "^2.2.0",
46+
"tslib": "^2.3.0",
4747
"zone.js": "~0.11.4"
4848
},
4949
"devDependencies": {
@@ -84,6 +84,6 @@
8484
"source-map-explorer": "^1.3.2",
8585
"ts-node": "~10.1.0",
8686
"tslint": "~6.1.0",
87-
"typescript": "~4.3.2"
87+
"typescript": "~4.4.2"
8888
}
8989
}

Diff for: aio/tools/examples/shared/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -11123,10 +11123,10 @@ [email protected]:
1112311123
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.4.tgz#3f85b986945bcf31071decdd96cf8bfa65f9dcbc"
1112411124
integrity sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew==
1112511125

11126-
typescript@~4.3.2:
11127-
version "4.3.5"
11128-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
11129-
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
11126+
typescript@~4.4.2:
11127+
version "4.4.2"
11128+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
11129+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
1113011130

1113111131
1113211132
version "0.7.17"

Diff for: aio/tools/firebase-test-utils/FirebaseRedirectSource.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class FirebaseRedirectSource {
4949

5050
return new FirebaseRedirectSource(`^${pattern}$`, restNamedGroups);
5151
} catch (err) {
52-
throw new Error(`Error in FirebaseRedirectSource: "${glob}" - ${err.message}`);
52+
throw new Error(`Error in FirebaseRedirectSource: "${glob}" - ${(err as Error).message}`);
5353
}
5454
}
5555

@@ -72,7 +72,7 @@ export class FirebaseRedirectSource {
7272
// capture groups.
7373
return new FirebaseRedirectSource(regex.replace(/(\(\?)P(<[^>]+>)/g, '$1$2'));
7474
} catch (err) {
75-
throw new Error(`Error in FirebaseRedirectSource: "${regex}" - ${err.message}`);
75+
throw new Error(`Error in FirebaseRedirectSource: "${regex}" - ${(err as Error).message}`);
7676
}
7777
}
7878

Diff for: aio/yarn.lock

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

12714-
tslib@^2.0.0, tslib@^2.0.1, tslib@^2.2.0:
12714+
tslib@^2.0.0, tslib@^2.0.1, tslib@^2.2.0, tslib@^2.3.0:
1271512715
version "2.3.1"
1271612716
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
1271712717
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
@@ -12850,10 +12850,10 @@ typescript@~3.2.2:
1285012850
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.4.tgz#c585cb952912263d915b462726ce244ba510ef3d"
1285112851
integrity sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg==
1285212852

12853-
typescript@~4.3.4:
12854-
version "4.3.5"
12855-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
12856-
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
12853+
typescript@~4.4.2:
12854+
version "4.4.2"
12855+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
12856+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
1285712857

1285812858
ua-parser-js@^0.7.28:
1285912859
version "0.7.28"

Diff for: 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
[

0 commit comments

Comments
 (0)