Skip to content

Commit fbd7f7d

Browse files
authored
Update typescript-eslint to latest (#43381)
1 parent eb804a9 commit fbd7f7d

File tree

13 files changed

+10697
-142
lines changed

13 files changed

+10697
-142
lines changed

package-lock.json

+10,657-105
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
"@types/source-map-support": "latest",
5454
"@types/through2": "latest",
5555
"@types/xml2js": "^0.4.0",
56-
"@typescript-eslint/eslint-plugin": "4.5.0",
57-
"@typescript-eslint/experimental-utils": "4.5.0",
58-
"@typescript-eslint/parser": "4.5.0",
56+
"@typescript-eslint/eslint-plugin": "^4.19.0",
57+
"@typescript-eslint/experimental-utils": "^4.19.0",
58+
"@typescript-eslint/parser": "^4.19.0",
5959
"async": "latest",
6060
"azure-devops-node-api": "^10.1.0",
6161
"browser-resolve": "^1.11.2",
@@ -94,7 +94,7 @@
9494
"remove-internal": "^2.9.2",
9595
"source-map-support": "latest",
9696
"through2": "latest",
97-
"typescript": "^4.0.0-dev.20200624",
97+
"typescript": "^4.2.3",
9898
"vinyl": "latest",
9999
"vinyl-sourcemaps-apply": "latest",
100100
"xml2js": "^0.4.19"
@@ -129,6 +129,5 @@
129129
},
130130
"volta": {
131131
"node": "14.15.5"
132-
},
133-
"dependencies": {}
132+
}
134133
}

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11616,7 +11616,7 @@ namespace ts {
1161611616
}
1161711617
}
1161811618

11619-
result.declarations = declarations!;
11619+
result.declarations = declarations;
1162011620
result.nameType = nameType;
1162111621
if (propTypes.length > 2) {
1162211622
// When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed

src/compiler/emitter.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,8 @@ namespace ts {
11661166
tempFlagsStack = [];
11671167
tempFlags = TempFlags.Auto;
11681168
reservedNamesStack = [];
1169-
currentSourceFile = undefined!;
1170-
currentLineMap = undefined!;
1169+
currentSourceFile = undefined;
1170+
currentLineMap = undefined;
11711171
detachedCommentsInfo = undefined;
11721172
setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
11731173
}
@@ -3153,10 +3153,10 @@ namespace ts {
31533153

31543154
let body = node.body;
31553155
if (!body) return writeTrailingSemicolon();
3156-
while (body.kind === SyntaxKind.ModuleDeclaration) {
3156+
while (body && isModuleDeclaration(body)) {
31573157
writePunctuation(".");
3158-
emit((<ModuleDeclaration>body).name);
3159-
body = (<ModuleDeclaration>body).body!;
3158+
emit(body.name);
3159+
body = body.body;
31603160
}
31613161

31623162
writeSpace();

src/compiler/factory/nodeFactory.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,9 @@ namespace ts {
555555
// NOTE: The following properties are commonly set by the binder and are added here to
556556
// ensure declarations have a stable shape.
557557
node.symbol = undefined!; // initialized by binder
558-
node.localSymbol = undefined!; // initialized by binder
559-
node.locals = undefined!; // initialized by binder
560-
node.nextContainer = undefined!; // initialized by binder
558+
node.localSymbol = undefined; // initialized by binder
559+
node.locals = undefined; // initialized by binder
560+
node.nextContainer = undefined; // initialized by binder
561561
return node;
562562
}
563563

src/compiler/parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ namespace ts {
10141014
jsDocDiagnostics = undefined!;
10151015
parsingContext = 0;
10161016
identifiers = undefined!;
1017-
notParenthesizedArrow = undefined!;
1017+
notParenthesizedArrow = undefined;
10181018
topLevel = true;
10191019
}
10201020

src/compiler/transformers/classFields.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ namespace ts {
534534
if (shouldTransformPrivateElements) {
535535
if (isDestructuringAssignment(node)) {
536536
const savedPendingExpressions = pendingExpressions;
537-
pendingExpressions = undefined!;
537+
pendingExpressions = undefined;
538538
node = factory.updateBinaryExpression(
539539
node,
540540
visitNode(node.left, visitorDestructuringTarget),

src/compiler/transformers/module/system.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ namespace ts {
133133
moduleInfo = undefined!;
134134
exportFunction = undefined!;
135135
contextObject = undefined!;
136-
hoistedStatements = undefined!;
136+
hoistedStatements = undefined;
137137
enclosingBlockScopedContainer = undefined!;
138138
return updated;
139139
}

src/compiler/utilities.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5628,8 +5628,8 @@ namespace ts {
56285628
function Symbol(this: Symbol, flags: SymbolFlags, name: __String) {
56295629
this.flags = flags;
56305630
this.escapedName = name;
5631-
this.declarations = undefined!;
5632-
this.valueDeclaration = undefined!;
5631+
this.declarations = undefined;
5632+
this.valueDeclaration = undefined;
56335633
this.id = undefined;
56345634
this.mergeId = undefined;
56355635
this.parent = undefined;

src/harness/fourslashImpl.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -962,12 +962,14 @@ namespace FourSlash {
962962
}
963963

964964
/** Use `getProgram` instead of accessing this directly. */
965-
private _program: ts.Program | undefined;
965+
private _program: ts.Program | undefined | "missing";
966966
/** Use `getChecker` instead of accessing this directly. */
967967
private _checker: ts.TypeChecker | undefined;
968968

969969
private getProgram(): ts.Program {
970-
return this._program || (this._program = this.languageService.getProgram()!); // TODO: GH#18217
970+
if (!this._program) this._program = this.languageService.getProgram() || "missing";
971+
if (this._program === "missing") ts.Debug.fail("Could not retrieve program from language service");
972+
return this._program;
971973
}
972974

973975
private getChecker() {

src/server/project.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ namespace ts.server {
772772

773773
this.rootFiles = undefined!;
774774
this.rootFilesMap = undefined!;
775-
this.externalFiles = undefined!;
776-
this.program = undefined!;
777-
this.builderState = undefined!;
775+
this.externalFiles = undefined;
776+
this.program = undefined;
777+
this.builderState = undefined;
778778
this.resolutionCache.clear();
779779
this.resolutionCache = undefined!;
780780
this.cachedUnresolvedImportsPerFile = undefined!;
@@ -784,7 +784,7 @@ namespace ts.server {
784784
// Clean up file watchers waiting for missing files
785785
if (this.missingFilesMap) {
786786
clearMap(this.missingFilesMap, closeFileWatcher);
787-
this.missingFilesMap = undefined!;
787+
this.missingFilesMap = undefined;
788788
}
789789
this.clearGeneratedFileWatch();
790790
this.clearInvalidateResolutionOfFailedLookupTimer();
@@ -1087,7 +1087,7 @@ namespace ts.server {
10871087
const start = timestamp();
10881088
this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution();
10891089
this.resolutionCache.startCachingPerDirectoryResolution();
1090-
this.program = this.languageService.getProgram()!; // TODO: GH#18217
1090+
this.program = this.languageService.getProgram(); // TODO: GH#18217
10911091
this.dirty = false;
10921092
this.resolutionCache.finishCachingPerDirectoryResolution();
10931093

@@ -1096,8 +1096,9 @@ namespace ts.server {
10961096
// bump up the version if
10971097
// - oldProgram is not set - this is a first time updateGraph is called
10981098
// - newProgram is different from the old program and structure of the old program was not reused.
1099-
const hasNewProgram = this.program && (!oldProgram || (this.program !== oldProgram && !(this.program.structureIsReused & StructureIsReused.Completely)));
1100-
if (hasNewProgram) {
1099+
let hasNewProgram = false;
1100+
if (this.program && (!oldProgram || (this.program !== oldProgram && !(this.program.structureIsReused & StructureIsReused.Completely)))) {
1101+
hasNewProgram = true;
11011102
if (oldProgram) {
11021103
for (const f of oldProgram.getSourceFiles()) {
11031104
const newFile = this.program.getSourceFileByPath(f.resolvedPath);
@@ -1163,7 +1164,7 @@ namespace ts.server {
11631164
}
11641165

11651166
if (!this.importSuggestionsCache.isEmpty()) {
1166-
if (this.hasAddedorRemovedFiles || oldProgram && !this.program.structureIsReused) {
1167+
if (this.hasAddedorRemovedFiles || oldProgram && !this.program!.structureIsReused) {
11671168
this.importSuggestionsCache.clear();
11681169
}
11691170
else if (this.dirtyFilesForSuggestions && oldProgram && this.program) {
@@ -1204,7 +1205,7 @@ namespace ts.server {
12041205
this.print(/*writeProjectFileNames*/ true);
12051206
}
12061207
else if (this.program !== oldProgram) {
1207-
this.writeLog(`Different program with same set of files:: structureIsReused:: ${this.program.structureIsReused}`);
1208+
this.writeLog(`Different program with same set of files:: structureIsReused:: ${this.program?.structureIsReused}`);
12081209
}
12091210
return hasNewProgram;
12101211
}

src/services/shims.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ namespace ts {
13261326
public close(): void {
13271327
// Forget all the registered shims
13281328
clear(this._shims);
1329-
this.documentRegistry = undefined!;
1329+
this.documentRegistry = undefined;
13301330
}
13311331

13321332
public registerShim(shim: Shim): void {

src/services/symbolDisplay.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ namespace ts.SymbolDisplay {
197197
}
198198

199199
if (callExpressionLike) {
200-
signature = typeChecker.getResolvedSignature(callExpressionLike)!; // TODO: GH#18217
200+
signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217
201201

202202
const useConstructSignatures = callExpressionLike.kind === SyntaxKind.NewExpression || (isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === SyntaxKind.SuperKeyword);
203203

204204
const allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
205205

206-
if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) {
206+
if (signature && !contains(allSignatures, signature.target) && !contains(allSignatures, signature)) {
207207
// Get the first signature if there is one -- allSignatures may contain
208208
// either the original signature or its target, so check for either
209209
signature = allSignatures.length ? allSignatures[0] : undefined;
@@ -278,7 +278,7 @@ namespace ts.SymbolDisplay {
278278
if (locationIsSymbolDeclaration) {
279279
const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures();
280280
if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
281-
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration)!; // TODO: GH#18217
281+
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); // TODO: GH#18217
282282
}
283283
else {
284284
signature = allSignatures[0];
@@ -294,8 +294,9 @@ namespace ts.SymbolDisplay {
294294
addPrefixForAnyFunctionOrVar(functionDeclaration.kind === SyntaxKind.CallSignature &&
295295
!(type.symbol.flags & SymbolFlags.TypeLiteral || type.symbol.flags & SymbolFlags.ObjectLiteral) ? type.symbol : symbol, symbolKind);
296296
}
297-
298-
addSignatureDisplayParts(signature, allSignatures);
297+
if (signature) {
298+
addSignatureDisplayParts(signature, allSignatures);
299+
}
299300
hasAddedSymbolInfo = true;
300301
hasMultipleSignatures = allSignatures.length > 1;
301302
}

0 commit comments

Comments
 (0)