Skip to content

Commit 3eedc65

Browse files
authored
build: update to typescript 4.5 and angular 13.1 (#24048)
Bumps the versions of TypeScript and Angular to 4.5 and 13.1 respectively, and accounts for some breaking changes.
1 parent 749edd8 commit 3eedc65

File tree

7 files changed

+940
-949
lines changed

7 files changed

+940
-949
lines changed

integration/ts-compat/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ write_file(
1313
# List of TypeScript packages that we want to run the compatibility test against.
1414
# The list contains NPM module names that resolve to the desired TypeScript version.
1515
typescript_version_packages = [
16+
"typescript-4.4",
1617
"typescript",
1718
]
1819

package.json

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
},
5252
"version": "13.1.0-next.3",
5353
"dependencies": {
54-
"@angular/animations": "13.0.1",
55-
"@angular/common": "13.0.1",
56-
"@angular/compiler": "13.0.1",
57-
"@angular/core": "13.0.1",
58-
"@angular/forms": "13.0.1",
59-
"@angular/platform-browser": "13.0.1",
54+
"@angular/animations": "^13.1.0-next.3",
55+
"@angular/common": "^13.1.0-next.3",
56+
"@angular/compiler": "^13.1.0-next.3",
57+
"@angular/core": "^13.1.0-next.3",
58+
"@angular/forms": "^13.1.0-next.3",
59+
"@angular/platform-browser": "^13.1.0-next.3",
6060
"@types/google.maps": "^3.45.6",
6161
"@types/youtube": "^0.0.42",
6262
"core-js-bundle": "^3.8.2",
@@ -67,17 +67,17 @@
6767
"zone.js": "~0.11.3"
6868
},
6969
"devDependencies": {
70-
"@angular-devkit/build-angular": "13.0.2",
71-
"@angular-devkit/core": "13.0.2",
72-
"@angular-devkit/schematics": "13.0.2",
73-
"@angular/bazel": "13.0.1",
74-
"@angular/cli": "13.0.2",
75-
"@angular/compiler-cli": "13.0.1",
70+
"@angular-devkit/build-angular": "^13.1.0-next.3",
71+
"@angular-devkit/core": "^13.1.0-next.3",
72+
"@angular-devkit/schematics": "^13.1.0-next.3",
73+
"@angular/bazel": "^13.1.0-next.3",
74+
"@angular/cli": "^13.1.0-next.3",
75+
"@angular/compiler-cli": "^13.1.0-next.3",
7676
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#c55a3937d45945489714273bfbbe9b803ceff89e",
77-
"@angular/localize": "13.0.1",
78-
"@angular/platform-browser-dynamic": "13.0.1",
79-
"@angular/platform-server": "13.0.1",
80-
"@angular/router": "13.0.1",
77+
"@angular/localize": "^13.1.0-next.3",
78+
"@angular/platform-browser-dynamic": "^13.1.0-next.3",
79+
"@angular/platform-server": "^13.1.0-next.3",
80+
"@angular/router": "^13.1.0-next.3",
8181
"@axe-core/webdriverjs": "^4.1.0",
8282
"@babel/core": "^7.16.0",
8383
"@bazel/bazelisk": "1.10.1",
@@ -142,7 +142,7 @@
142142
"@octokit/rest": "18.3.5",
143143
"@rollup/plugin-commonjs": "^21.0.0",
144144
"@rollup/plugin-node-resolve": "^13.0.5",
145-
"@schematics/angular": "13.0.2",
145+
"@schematics/angular": "^13.1.0-next.3",
146146
"@types/babel__core": "^7.1.16",
147147
"@types/browser-sync": "^2.26.1",
148148
"@types/fs-extra": "^9.0.5",
@@ -214,14 +214,15 @@
214214
"tsickle": "0.39.1",
215215
"tslint": "^6.1.3",
216216
"tsutils": "^3.21.0",
217-
"typescript": "~4.4.2",
217+
"typescript-4.4": "npm:[email protected]",
218+
"typescript": "~4.5.2",
218219
"vrsource-tslint-rules": "6.0.0",
219220
"yaml": "^1.10.0"
220221
},
221222
"resolutions": {
222-
"@angular/dev-infra-private/typescript": "~4.4.2",
223+
"@angular/dev-infra-private/typescript": "~4.5.2",
223224
"browser-sync-client": "2.26.13",
224-
"dgeni-packages/typescript": "4.4.2",
225+
"dgeni-packages/typescript": "4.5.2",
225226
"**/https-proxy-agent": "5.0.0"
226227
}
227228
}

scripts/caretaking/firebase-functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"firebase-functions": "^3.11.0"
1212
},
1313
"devDependencies": {
14-
"typescript": "^4.4.2",
14+
"typescript": "^4.5.2",
1515
"firebase-tools": "^8.6.0"
1616
},
1717
"private": true

scripts/caretaking/firebase-functions/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3794,10 +3794,10 @@ typedarray@^0.0.6:
37943794
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
37953795
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
37963796

3797-
typescript@^4.4.2:
3798-
version "4.4.3"
3799-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324"
3800-
integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==
3797+
typescript@^4.5.2:
3798+
version "4.5.2"
3799+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998"
3800+
integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==
38013801

38023802
unique-string@^1.0.0:
38033803
version "1.0.0"

src/cdk/schematics/utils/build-component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {InsertChange} from '@schematics/angular/utility/change';
2727
import {getWorkspace} from '@schematics/angular/utility/workspace';
2828
import {buildRelativePath, findModuleFromOptions} from '@schematics/angular/utility/find-module';
2929
import {parseName} from '@schematics/angular/utility/parse-name';
30-
import {validateHtmlSelector, validateName} from '@schematics/angular/utility/validation';
30+
import {validateHtmlSelector} from '@schematics/angular/utility/validation';
3131
import {ProjectType} from '@schematics/angular/utility/workspace-models';
3232
import {readFileSync, statSync} from 'fs';
3333
import {dirname, join, resolve} from 'path';
@@ -200,7 +200,6 @@ export function buildComponent(
200200
options.path = parsedPath.path;
201201
options.selector = options.selector || buildSelector(options, project.prefix);
202202

203-
validateName(options.name);
204203
validateHtmlSelector(options.selector!);
205204

206205
// In case the specified style extension is not part of the supported CSS supersets,

src/material/schematics/ng-update/migrations/hammer-gestures-v9/import-manager.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ interface AnalyzedImport {
3939
/** Checks whether an analyzed import has the given import flag set. */
4040
const hasFlag = (data: AnalyzedImport, flag: ImportState) => (data.state & flag) !== 0;
4141

42+
/** Parsed version of TypeScript that can be used for comparisons. */
43+
const PARSED_TS_VERSION = parseFloat(ts.versionMajorMinor);
44+
4245
/**
4346
* Import manager that can be used to add or remove TypeScript imports within source
4447
* files. The manager ensures that multiple transformations are applied properly
@@ -346,7 +349,7 @@ export class ImportManager {
346349
if (importData.specifiers) {
347350
const namedBindings = importData.node.importClause!.namedBindings as ts.NamedImports;
348351
const importSpecifiers = importData.specifiers.map(s =>
349-
ts.createImportSpecifier(s.propertyName, s.name),
352+
createImportSpecifier(s.propertyName, s.name),
350353
);
351354
const updatedBindings = ts.updateNamedImports(namedBindings, importSpecifiers);
352355

@@ -355,12 +358,14 @@ export class ImportManager {
355358
// update the named bindings to not re-print the whole import (which could
356359
// cause unnecessary formatting changes)
357360
if (hasFlag(importData, ImportState.ADDED)) {
358-
const updatedImport = ts.updateImportDeclaration(
361+
// TODO(crisbeto): needs to be cast to any until g3 is updated to TS 4.5.
362+
const updatedImport = (ts.updateImportDeclaration as any)(
359363
importData.node,
360364
undefined,
361365
undefined,
362366
ts.createImportClause(undefined, updatedBindings),
363367
ts.createStringLiteral(importData.moduleName),
368+
undefined,
364369
);
365370
const newImportText = this._printer.printNode(
366371
ts.EmitHint.Unspecified,
@@ -523,3 +528,14 @@ export class ImportManager {
523528
return commentRanges[commentRanges.length - 1]!.end;
524529
}
525530
}
531+
532+
// TODO(crisbeto): backwards-compatibility layer that allows us to support both TS 4.4 and 4.5.
533+
// Should be removed once we don't have to support 4.4 anymore.
534+
function createImportSpecifier(
535+
propertyName: ts.Identifier | undefined,
536+
name: ts.Identifier,
537+
): ts.ImportSpecifier {
538+
return PARSED_TS_VERSION > 4.4
539+
? (ts.createImportSpecifier as any)(false, propertyName, name)
540+
: (ts.createImportSpecifier as any)(propertyName, name);
541+
}

0 commit comments

Comments
 (0)