Skip to content

Commit b9129fa

Browse files
committed
refactor(multiple): add support for TypeScript 4.3
Switches the repository to TypeScript 4.3. Also updates the tslib dependency.
1 parent 2f272a8 commit b9129fa

File tree

13 files changed

+42
-29
lines changed

13 files changed

+42
-29
lines changed

angular-tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"angularCompilerOptions": {
66
// In snapshot builds the compiler-cli will now use ngtsc by default. In
77
// order to be able to build the summary files, we need to use ngc.
8-
"enableIvy": false
8+
"enableIvy": false,
9+
"disableTypeScriptVersionCheck": true
910
},
1011
"compilerOptions": {
1112
"module": "umd",

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.2",
1617
"typescript",
1718
]
1819

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"rxjs": "^6.5.3",
6868
"rxjs-tslint-rules": "^4.33.1",
6969
"systemjs": "0.19.43",
70-
"tslib": "^2.1.0",
70+
"tslib": "^2.2.0",
7171
"zone.js": "~0.11.3"
7272
},
7373
"devDependencies": {
@@ -222,12 +222,13 @@
222222
"tsickle": "0.39.1",
223223
"tslint": "^6.1.3",
224224
"tsutils": "^3.17.1",
225-
"typescript": "~4.2.3",
225+
"typescript": "~4.3.2",
226+
"typescript-4.2": "npm:typescript@~4.2.4",
226227
"vrsource-tslint-rules": "6.0.0",
227228
"yaml": "^1.10.0"
228229
},
229230
"resolutions": {
230231
"browser-sync-client": "2.26.13",
231-
"dgeni-packages/typescript": "4.2.3"
232+
"dgeni-packages/typescript": "4.3.2"
232233
}
233234
}

packages.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# version for the placeholders.
44
ANGULAR_PACKAGE_VERSION = "^12.0.0 || ^13.0.0-0"
55
MDC_PACKAGE_VERSION = "^12.0.0-canary.a23ecb682.0"
6-
TSLIB_PACKAGE_VERSION = "^2.1.0"
6+
TSLIB_PACKAGE_VERSION = "^2.2.0"
77
RXJS_PACKAGE_VERSION = "^6.5.3"
88

99
# Each placer holder is used to stamp versions during the build process, replacing the key with it's

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.0.2",
14+
"typescript": "^4.3.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.0.2:
3798-
version "4.0.3"
3799-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"
3800-
integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==
3797+
typescript@^4.3.2:
3798+
version "4.3.2"
3799+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
3800+
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==
38013801

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

src/bazel-tsconfig-build.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@
3737
"suppressTsconfigOverrideWarnings": true,
3838
// See https://github.com/angular/angular/issues/29107
3939
"devmodeTargetOverride": "es5"
40+
},
41+
"angularCompilerOptions": {
42+
"disableTypeScriptVersionCheck": true
4043
}
4144
}

src/cdk/schematics/ng-update/migrations/constructor-signature.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ export class ConstructorSignatureMigration extends Migration<UpgradeData> {
9494
signature => getParameterTypesFromSignature(signature, this.typeChecker));
9595

9696
const expressionName = isNewExpression ? `new ${className}` : 'super';
97-
const signatures =
98-
classSignatures.map(signature => signature.map(t => this.typeChecker.typeToString(t)))
99-
.map(signature => `${expressionName}(${signature.join(', ')})`)
100-
.join(' or ');
97+
const signatures = classSignatures
98+
.map(signature =>
99+
signature.map(t => t === null ? 'any' : this.typeChecker.typeToString(t)))
100+
.map(signature => `${expressionName}(${signature.join(', ')})`)
101+
.join(' or ');
101102

102103
this.createFailureAtNode(
103104
node,
@@ -111,9 +112,9 @@ export class ConstructorSignatureMigration extends Migration<UpgradeData> {
111112

112113
/** Resolves the type for each parameter in the specified signature. */
113114
function getParameterTypesFromSignature(
114-
signature: ts.Signature, typeChecker: ts.TypeChecker): ts.Type[] {
115+
signature: ts.Signature, typeChecker: ts.TypeChecker): (ts.Type|null)[] {
115116
return signature.getParameters().map(
116-
param => typeChecker.getTypeAtLocation(param.declarations[0]));
117+
param => param.declarations ? typeChecker.getTypeAtLocation(param.declarations[0]) : null);
117118
}
118119

119120
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ export class HammerGesturesMigration extends DevkitMigration<null> {
648648
const mainFilePath = getProjectMainFile(project);
649649
const rootModuleSymbol = this._getRootModuleSymbol(mainFilePath);
650650

651-
if (rootModuleSymbol === null) {
651+
if (rootModuleSymbol === null || rootModuleSymbol.valueDeclaration === undefined) {
652652
this.failures.push({
653653
filePath: mainFilePath,
654654
message: `Could not setup Hammer gestures in module. Please ` +
@@ -726,7 +726,7 @@ export class HammerGesturesMigration extends DevkitMigration<null> {
726726
const mainFilePath = getProjectMainFile(project);
727727
const rootModuleSymbol = this._getRootModuleSymbol(mainFilePath);
728728

729-
if (rootModuleSymbol === null) {
729+
if (rootModuleSymbol === null || rootModuleSymbol.valueDeclaration === undefined) {
730730
this.failures.push({
731731
filePath: mainFilePath,
732732
message: `Could not setup HammerModule. Please manually set up the "HammerModule" ` +

src/material/schematics/ng-update/migrations/package-imports-v8/secondary-entry-points-migration.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function getDeclarationSymbolOfNode(node: ts.Node, checker: ts.TypeChecker): ts.
169169

170170

171171
/** Tries to resolve the name of the Material module that a node is imported from. */
172-
function resolveModuleName(node: ts.Identifier, typeChecker: ts.TypeChecker) {
172+
function resolveModuleName(node: ts.Identifier, typeChecker: ts.TypeChecker): string|null {
173173
// Get the symbol for the named binding element. Note that we cannot determine the
174174
// value declaration based on the type of the element as types are not necessarily
175175
// specific to a given secondary entry-point (e.g. exports with the type of "string")
@@ -186,7 +186,12 @@ function resolveModuleName(node: ts.Identifier, typeChecker: ts.TypeChecker) {
186186
// The filename for the source file of the node that contains the
187187
// first declaration of the symbol. All symbol declarations must be
188188
// part of a defining node, so parent can be asserted to be defined.
189-
const resolvedNode = symbol.valueDeclaration || symbol.declarations[0];
189+
const resolvedNode = symbol.valueDeclaration || symbol.declarations?.[0];
190+
191+
if (resolvedNode === undefined) {
192+
return null;
193+
}
194+
190195
const sourceFile = resolvedNode.getSourceFile().fileName;
191196

192197
// File the module the symbol belongs to from a regex match of the

tools/tslint-rules/coercionTypesRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class Walker extends Lint.RuleWalker {
128128
}
129129

130130
const symbol = this._typeChecker.getTypeAtLocation(baseType).getSymbol();
131-
currentClass = symbol && ts.isClassDeclaration(symbol.valueDeclaration) ?
131+
currentClass = symbol?.valueDeclaration && ts.isClassDeclaration(symbol.valueDeclaration) ?
132132
symbol.valueDeclaration : null;
133133

134134
if (currentClass) {

tools/tslint-rules/noUndecoratedBaseClassDiRule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class Walker extends Lint.RuleWalker {
7272
return null;
7373
}
7474
const symbol = this._typeChecker.getTypeAtLocation(baseTypes[0]).getSymbol();
75-
if (!symbol || !ts.isClassDeclaration(symbol.valueDeclaration)) {
75+
if (symbol?.valueDeclaration === undefined ||
76+
!ts.isClassDeclaration(symbol.valueDeclaration)) {
7677
return null;
7778
}
7879
if (this.hasExplicitConstructor(symbol.valueDeclaration)) {

yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13623,7 +13623,7 @@ tsickle@^0.38.0:
1362313623
resolved "https://registry.yarnpkg.com/tsickle/-/tsickle-0.38.1.tgz#30762db759d40c435943093b6972c7f2efb384ef"
1362413624
integrity sha512-4xZfvC6+etRu6ivKCNqMOd1FqcY/m6JY3Y+yr5+Xw+i751ciwrWINi6x/3l1ekcODH9GZhlf0ny2LpzWxnjWYA==
1362513625

13626-
13626+
[email protected], tslib@^2.2.0:
1362713627
version "2.2.0"
1362813628
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
1362913629
integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==
@@ -13760,16 +13760,16 @@ typedarray@^0.0.6:
1376013760
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1376113761
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1376213762

13763-
[email protected], typescript@^3.2.2, typescript@~4.2.3:
13764-
version "4.2.3"
13765-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
13766-
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
13767-
13768-
[email protected], typescript@~4.2.4:
13763+
"typescript-4.2@npm:typescript@~4.2.4", [email protected], typescript@~4.2.4:
1376913764
version "4.2.4"
1377013765
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
1377113766
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
1377213767

13768+
[email protected], typescript@^3.2.2, typescript@~4.3.2:
13769+
version "4.3.2"
13770+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
13771+
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==
13772+
1377313773
typescript@^3.9.5, typescript@^3.9.7:
1377413774
version "3.9.7"
1377513775
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"

0 commit comments

Comments
 (0)