@typescript-deploys/pr-build 5.3.0-pr-55860-30 → 5.3.0-pr-55887-24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +106 -94
- package/lib/tsserver.js +106 -94
- package/lib/typescript.js +106 -94
- package/lib/typingsInstaller.js +0 -1
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -6651,7 +6651,6 @@ var Diagnostics = {
|
|
|
6651
6651
|
Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
|
|
6652
6652
|
Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
|
|
6653
6653
|
Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
|
|
6654
|
-
The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1: diag(2860, 1 /* Error */, "The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1_2860", "The type of this declaration is ambiguous and may be observed as either '{0}' or '{1}'."),
|
|
6655
6654
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
6656
6655
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
6657
6656
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -15862,6 +15861,9 @@ function accessKind(node) {
|
|
|
15862
15861
|
return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent);
|
|
15863
15862
|
case 209 /* ArrayLiteralExpression */:
|
|
15864
15863
|
return accessKind(parent);
|
|
15864
|
+
case 249 /* ForInStatement */:
|
|
15865
|
+
case 250 /* ForOfStatement */:
|
|
15866
|
+
return node === parent.initializer ? 1 /* Write */ : 0 /* Read */;
|
|
15865
15867
|
default:
|
|
15866
15868
|
return 0 /* Read */;
|
|
15867
15869
|
}
|
|
@@ -43525,11 +43527,16 @@ function createTypeChecker(host) {
|
|
|
43525
43527
|
checkSourceFileWithEagerDiagnostics(file);
|
|
43526
43528
|
Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
43527
43529
|
diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
43528
|
-
|
|
43529
|
-
|
|
43530
|
-
|
|
43531
|
-
|
|
43532
|
-
|
|
43530
|
+
checkUnusedOrUninitializedIdentifiers(
|
|
43531
|
+
getPotentiallyUnusedOrUninitializedIdentifiers(file),
|
|
43532
|
+
(containingNode, kind, diag2) => {
|
|
43533
|
+
if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
|
|
43534
|
+
(diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
|
|
43535
|
+
}
|
|
43536
|
+
},
|
|
43537
|
+
/*checkUnused*/
|
|
43538
|
+
true
|
|
43539
|
+
);
|
|
43533
43540
|
return diagnostics2 || emptyArray;
|
|
43534
43541
|
} finally {
|
|
43535
43542
|
cancellationToken = void 0;
|
|
@@ -44026,7 +44033,7 @@ function createTypeChecker(host) {
|
|
|
44026
44033
|
var deferredGlobalClassAccessorDecoratorTargetType;
|
|
44027
44034
|
var deferredGlobalClassAccessorDecoratorResultType;
|
|
44028
44035
|
var deferredGlobalClassFieldDecoratorContextType;
|
|
44029
|
-
var
|
|
44036
|
+
var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
|
|
44030
44037
|
var flowLoopStart = 0;
|
|
44031
44038
|
var flowLoopCount = 0;
|
|
44032
44039
|
var sharedFlowCount = 0;
|
|
@@ -44069,7 +44076,6 @@ function createTypeChecker(host) {
|
|
|
44069
44076
|
var potentialReflectCollisions = [];
|
|
44070
44077
|
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
44071
44078
|
var awaitedTypeStack = [];
|
|
44072
|
-
var ambiguousVariableDeclarationsWhenWidened = [];
|
|
44073
44079
|
var diagnostics = createDiagnosticCollection();
|
|
44074
44080
|
var suggestionDiagnostics = createDiagnosticCollection();
|
|
44075
44081
|
var typeofType = createTypeofType();
|
|
@@ -44738,10 +44744,10 @@ function createTypeChecker(host) {
|
|
|
44738
44744
|
function isConstAssertion(location) {
|
|
44739
44745
|
return isAssertionExpression(location) && isConstTypeReference(location.type) || isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression);
|
|
44740
44746
|
}
|
|
44741
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true) {
|
|
44742
|
-
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol);
|
|
44747
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true, isWritten = false) {
|
|
44748
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, getSymbol);
|
|
44743
44749
|
}
|
|
44744
|
-
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
44750
|
+
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, lookup) {
|
|
44745
44751
|
var _a, _b, _c;
|
|
44746
44752
|
const originalLocation = location;
|
|
44747
44753
|
let result;
|
|
@@ -44967,6 +44973,9 @@ function createTypeChecker(host) {
|
|
|
44967
44973
|
if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
|
|
44968
44974
|
result.isReferenced |= meaning;
|
|
44969
44975
|
}
|
|
44976
|
+
if (isWritten && result) {
|
|
44977
|
+
result.isAssigned = true;
|
|
44978
|
+
}
|
|
44970
44979
|
if (!result) {
|
|
44971
44980
|
if (lastLocation) {
|
|
44972
44981
|
Debug.assertNode(lastLocation, isSourceFile);
|
|
@@ -64474,7 +64483,10 @@ function createTypeChecker(host) {
|
|
|
64474
64483
|
node,
|
|
64475
64484
|
!isWriteOnlyAccess(node),
|
|
64476
64485
|
/*excludeGlobals*/
|
|
64477
|
-
false
|
|
64486
|
+
false,
|
|
64487
|
+
/*getSpellingSuggestions*/
|
|
64488
|
+
void 0,
|
|
64489
|
+
isWriteAccess(node)
|
|
64478
64490
|
) || unknownSymbol;
|
|
64479
64491
|
}
|
|
64480
64492
|
return links.resolvedSymbol;
|
|
@@ -69908,6 +69920,8 @@ function createTypeChecker(host) {
|
|
|
69908
69920
|
false,
|
|
69909
69921
|
/*getSpellingSuggestions*/
|
|
69910
69922
|
true,
|
|
69923
|
+
/*isWritten*/
|
|
69924
|
+
false,
|
|
69911
69925
|
(symbols, name, meaning2) => {
|
|
69912
69926
|
Debug.assertEqual(outerName, name, "name should equal outerName");
|
|
69913
69927
|
const symbol = getSymbol(symbols, name, meaning2);
|
|
@@ -75362,7 +75376,7 @@ function createTypeChecker(host) {
|
|
|
75362
75376
|
}
|
|
75363
75377
|
}
|
|
75364
75378
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
75365
|
-
|
|
75379
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
75366
75380
|
}
|
|
75367
75381
|
}
|
|
75368
75382
|
}
|
|
@@ -75907,7 +75921,7 @@ function createTypeChecker(host) {
|
|
|
75907
75921
|
}
|
|
75908
75922
|
}
|
|
75909
75923
|
}
|
|
75910
|
-
|
|
75924
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
75911
75925
|
}
|
|
75912
75926
|
function checkTemplateLiteralType(node) {
|
|
75913
75927
|
for (const span of node.templateSpans) {
|
|
@@ -76893,25 +76907,27 @@ function createTypeChecker(host) {
|
|
|
76893
76907
|
}
|
|
76894
76908
|
}
|
|
76895
76909
|
}
|
|
76896
|
-
function
|
|
76897
|
-
addLazyDiagnostic(
|
|
76898
|
-
function
|
|
76910
|
+
function registerForUnusedOrUninitializedIdentifiersCheck(node) {
|
|
76911
|
+
addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
|
|
76912
|
+
function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
|
|
76899
76913
|
const sourceFile = getSourceFileOfNode(node);
|
|
76900
|
-
let
|
|
76901
|
-
if (!
|
|
76902
|
-
|
|
76903
|
-
|
|
76914
|
+
let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
|
|
76915
|
+
if (!potentiallyUnusedOrUninitializedIdentifiers) {
|
|
76916
|
+
potentiallyUnusedOrUninitializedIdentifiers = [];
|
|
76917
|
+
allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
|
|
76904
76918
|
}
|
|
76905
|
-
|
|
76919
|
+
potentiallyUnusedOrUninitializedIdentifiers.push(node);
|
|
76906
76920
|
}
|
|
76907
76921
|
}
|
|
76908
|
-
function
|
|
76922
|
+
function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
|
|
76909
76923
|
for (const node of potentiallyUnusedIdentifiers) {
|
|
76910
76924
|
switch (node.kind) {
|
|
76911
76925
|
case 263 /* ClassDeclaration */:
|
|
76912
76926
|
case 231 /* ClassExpression */:
|
|
76913
|
-
|
|
76914
|
-
|
|
76927
|
+
if (checkUnused) {
|
|
76928
|
+
checkUnusedClassMembers(node, addDiagnostic);
|
|
76929
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
76930
|
+
}
|
|
76915
76931
|
break;
|
|
76916
76932
|
case 312 /* SourceFile */:
|
|
76917
76933
|
case 267 /* ModuleDeclaration */:
|
|
@@ -76920,7 +76936,12 @@ function createTypeChecker(host) {
|
|
|
76920
76936
|
case 248 /* ForStatement */:
|
|
76921
76937
|
case 249 /* ForInStatement */:
|
|
76922
76938
|
case 250 /* ForOfStatement */:
|
|
76923
|
-
|
|
76939
|
+
if (checkUnused) {
|
|
76940
|
+
checkUnusedLocalsAndParameters(node, addDiagnostic);
|
|
76941
|
+
}
|
|
76942
|
+
if (checkUninitialized) {
|
|
76943
|
+
checkUninitializedLocals(node);
|
|
76944
|
+
}
|
|
76924
76945
|
break;
|
|
76925
76946
|
case 176 /* Constructor */:
|
|
76926
76947
|
case 218 /* FunctionExpression */:
|
|
@@ -76929,10 +76950,15 @@ function createTypeChecker(host) {
|
|
|
76929
76950
|
case 174 /* MethodDeclaration */:
|
|
76930
76951
|
case 177 /* GetAccessor */:
|
|
76931
76952
|
case 178 /* SetAccessor */:
|
|
76932
|
-
if (
|
|
76933
|
-
|
|
76953
|
+
if (checkUnused) {
|
|
76954
|
+
if (node.body) {
|
|
76955
|
+
checkUnusedLocalsAndParameters(node, addDiagnostic);
|
|
76956
|
+
}
|
|
76957
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
76958
|
+
}
|
|
76959
|
+
if (checkUninitialized) {
|
|
76960
|
+
checkUninitializedLocals(node);
|
|
76934
76961
|
}
|
|
76935
|
-
checkUnusedTypeParameters(node, addDiagnostic);
|
|
76936
76962
|
break;
|
|
76937
76963
|
case 173 /* MethodSignature */:
|
|
76938
76964
|
case 179 /* CallSignature */:
|
|
@@ -76941,10 +76967,14 @@ function createTypeChecker(host) {
|
|
|
76941
76967
|
case 185 /* ConstructorType */:
|
|
76942
76968
|
case 265 /* TypeAliasDeclaration */:
|
|
76943
76969
|
case 264 /* InterfaceDeclaration */:
|
|
76944
|
-
|
|
76970
|
+
if (checkUnused) {
|
|
76971
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
76972
|
+
}
|
|
76945
76973
|
break;
|
|
76946
76974
|
case 195 /* InferType */:
|
|
76947
|
-
|
|
76975
|
+
if (checkUnused) {
|
|
76976
|
+
checkUnusedInferTypeParameter(node, addDiagnostic);
|
|
76977
|
+
}
|
|
76948
76978
|
break;
|
|
76949
76979
|
default:
|
|
76950
76980
|
Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
|
|
@@ -77134,6 +77164,26 @@ function createTypeChecker(host) {
|
|
|
77134
77164
|
}
|
|
77135
77165
|
});
|
|
77136
77166
|
}
|
|
77167
|
+
function checkUninitializedLocals(nodeWithLocals) {
|
|
77168
|
+
nodeWithLocals.locals.forEach((local) => {
|
|
77169
|
+
if (!(local.flags & 3 /* Variable */) || local.isAssigned || !local.isReferenced) {
|
|
77170
|
+
return;
|
|
77171
|
+
}
|
|
77172
|
+
const declaration = local.valueDeclaration;
|
|
77173
|
+
if (!declaration) {
|
|
77174
|
+
return;
|
|
77175
|
+
}
|
|
77176
|
+
if (isVariableDeclaration(declaration)) {
|
|
77177
|
+
if (getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
|
|
77178
|
+
return;
|
|
77179
|
+
}
|
|
77180
|
+
const type = getTypeFromTypeNode(declaration.type);
|
|
77181
|
+
if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
|
|
77182
|
+
error(declaration, Diagnostics.Variable_0_is_used_before_being_assigned, idText(declaration.name));
|
|
77183
|
+
}
|
|
77184
|
+
}
|
|
77185
|
+
});
|
|
77186
|
+
}
|
|
77137
77187
|
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
77138
77188
|
var _a;
|
|
77139
77189
|
for (const node of potentialUnusedRenamedBindingElementsInTypes) {
|
|
@@ -77180,7 +77230,7 @@ function createTypeChecker(host) {
|
|
|
77180
77230
|
forEach(node.statements, checkSourceElement);
|
|
77181
77231
|
}
|
|
77182
77232
|
if (node.locals) {
|
|
77183
|
-
|
|
77233
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
77184
77234
|
}
|
|
77185
77235
|
}
|
|
77186
77236
|
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
|
@@ -77529,29 +77579,6 @@ function createTypeChecker(host) {
|
|
|
77529
77579
|
}
|
|
77530
77580
|
checkCollisionsForDeclarationName(node, node.name);
|
|
77531
77581
|
}
|
|
77532
|
-
function canHaveLiteralInitializer2(node2) {
|
|
77533
|
-
switch (node2.kind) {
|
|
77534
|
-
case 172 /* PropertyDeclaration */:
|
|
77535
|
-
case 171 /* PropertySignature */:
|
|
77536
|
-
return !hasEffectiveModifier(node2, 8 /* Private */);
|
|
77537
|
-
case 169 /* Parameter */:
|
|
77538
|
-
case 260 /* VariableDeclaration */:
|
|
77539
|
-
return true;
|
|
77540
|
-
}
|
|
77541
|
-
return false;
|
|
77542
|
-
}
|
|
77543
|
-
function shouldPrintWithInitializer(node2) {
|
|
77544
|
-
return canHaveLiteralInitializer2(node2) && isLiteralConstDeclaration(node2);
|
|
77545
|
-
}
|
|
77546
|
-
function isPrivateDeclaration(node2) {
|
|
77547
|
-
return hasEffectiveModifier(node2, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(node2);
|
|
77548
|
-
}
|
|
77549
|
-
if (getEmitDeclarations(compilerOptions) && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) && !shouldPrintWithInitializer(node) && !isPrivateDeclaration(node)) {
|
|
77550
|
-
const widenedLiteralType = getWidenedLiteralType(type);
|
|
77551
|
-
if (!isTypeIdenticalTo(type, widenedLiteralType)) {
|
|
77552
|
-
ambiguousVariableDeclarationsWhenWidened.push([node, type, widenedLiteralType]);
|
|
77553
|
-
}
|
|
77554
|
-
}
|
|
77555
77582
|
}
|
|
77556
77583
|
function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
|
|
77557
77584
|
const nextDeclarationName = getNameOfDeclaration(nextDeclaration);
|
|
@@ -77753,7 +77780,7 @@ function createTypeChecker(host) {
|
|
|
77753
77780
|
checkExpression(node.incrementor);
|
|
77754
77781
|
checkSourceElement(node.statement);
|
|
77755
77782
|
if (node.locals) {
|
|
77756
|
-
|
|
77783
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
77757
77784
|
}
|
|
77758
77785
|
}
|
|
77759
77786
|
function checkForOfStatement(node) {
|
|
@@ -77792,7 +77819,7 @@ function createTypeChecker(host) {
|
|
|
77792
77819
|
}
|
|
77793
77820
|
checkSourceElement(node.statement);
|
|
77794
77821
|
if (node.locals) {
|
|
77795
|
-
|
|
77822
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
77796
77823
|
}
|
|
77797
77824
|
}
|
|
77798
77825
|
function checkForInStatement(node) {
|
|
@@ -77824,7 +77851,7 @@ function createTypeChecker(host) {
|
|
|
77824
77851
|
}
|
|
77825
77852
|
checkSourceElement(node.statement);
|
|
77826
77853
|
if (node.locals) {
|
|
77827
|
-
|
|
77854
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
77828
77855
|
}
|
|
77829
77856
|
}
|
|
77830
77857
|
function checkRightHandSideOfForOf(statement) {
|
|
@@ -78556,7 +78583,7 @@ function createTypeChecker(host) {
|
|
|
78556
78583
|
}
|
|
78557
78584
|
});
|
|
78558
78585
|
if (node.caseBlock.locals) {
|
|
78559
|
-
|
|
78586
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
|
|
78560
78587
|
}
|
|
78561
78588
|
}
|
|
78562
78589
|
function checkLabeledStatement(node) {
|
|
@@ -78896,7 +78923,7 @@ function createTypeChecker(host) {
|
|
|
78896
78923
|
}
|
|
78897
78924
|
function checkClassExpressionDeferred(node) {
|
|
78898
78925
|
forEach(node.members, checkSourceElement);
|
|
78899
|
-
|
|
78926
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
78900
78927
|
}
|
|
78901
78928
|
function checkClassDeclaration(node) {
|
|
78902
78929
|
const firstDecorator = find(node.modifiers, isDecorator);
|
|
@@ -78908,7 +78935,7 @@ function createTypeChecker(host) {
|
|
|
78908
78935
|
}
|
|
78909
78936
|
checkClassLikeDeclaration(node);
|
|
78910
78937
|
forEach(node.members, checkSourceElement);
|
|
78911
|
-
|
|
78938
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
78912
78939
|
}
|
|
78913
78940
|
function checkClassLikeDeclaration(node) {
|
|
78914
78941
|
checkGrammarClassLikeDeclaration(node);
|
|
@@ -79469,7 +79496,7 @@ function createTypeChecker(host) {
|
|
|
79469
79496
|
forEach(node.members, checkSourceElement);
|
|
79470
79497
|
addLazyDiagnostic(() => {
|
|
79471
79498
|
checkTypeForDuplicateIndexSignatures(node);
|
|
79472
|
-
|
|
79499
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
79473
79500
|
});
|
|
79474
79501
|
}
|
|
79475
79502
|
function checkTypeAliasDeclaration(node) {
|
|
@@ -79483,7 +79510,7 @@ function createTypeChecker(host) {
|
|
|
79483
79510
|
}
|
|
79484
79511
|
} else {
|
|
79485
79512
|
checkSourceElement(node.type);
|
|
79486
|
-
|
|
79513
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
79487
79514
|
}
|
|
79488
79515
|
}
|
|
79489
79516
|
function computeEnumMemberValues(node) {
|
|
@@ -79754,7 +79781,7 @@ function createTypeChecker(host) {
|
|
|
79754
79781
|
if (node.body) {
|
|
79755
79782
|
checkSourceElement(node.body);
|
|
79756
79783
|
if (!isGlobalScopeAugmentation(node)) {
|
|
79757
|
-
|
|
79784
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
79758
79785
|
}
|
|
79759
79786
|
}
|
|
79760
79787
|
addLazyDiagnostic(checkModuleDeclarationDiagnostics);
|
|
@@ -80752,8 +80779,8 @@ function createTypeChecker(host) {
|
|
|
80752
80779
|
return Debug.assertNever(kind);
|
|
80753
80780
|
}
|
|
80754
80781
|
}
|
|
80755
|
-
function
|
|
80756
|
-
return
|
|
80782
|
+
function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
|
|
80783
|
+
return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
|
|
80757
80784
|
}
|
|
80758
80785
|
function checkSourceFileWorker(node) {
|
|
80759
80786
|
const links = getNodeLinks(node);
|
|
@@ -80767,42 +80794,30 @@ function createTypeChecker(host) {
|
|
|
80767
80794
|
clear(potentialWeakMapSetCollisions);
|
|
80768
80795
|
clear(potentialReflectCollisions);
|
|
80769
80796
|
clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
80770
|
-
clear(ambiguousVariableDeclarationsWhenWidened);
|
|
80771
80797
|
forEach(node.statements, checkSourceElement);
|
|
80772
80798
|
checkSourceElement(node.endOfFileToken);
|
|
80773
80799
|
checkDeferredNodes(node);
|
|
80774
80800
|
if (isExternalOrCommonJsModule(node)) {
|
|
80775
|
-
|
|
80801
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
80776
80802
|
}
|
|
80777
80803
|
addLazyDiagnostic(() => {
|
|
80778
|
-
|
|
80779
|
-
|
|
80780
|
-
|
|
80781
|
-
|
|
80782
|
-
|
|
80783
|
-
|
|
80804
|
+
const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
|
|
80805
|
+
if (checkUnused || strictNullChecks) {
|
|
80806
|
+
checkUnusedOrUninitializedIdentifiers(
|
|
80807
|
+
getPotentiallyUnusedOrUninitializedIdentifiers(node),
|
|
80808
|
+
(containingNode, kind, diag2) => {
|
|
80809
|
+
if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
|
|
80810
|
+
diagnostics.add(diag2);
|
|
80811
|
+
}
|
|
80812
|
+
},
|
|
80813
|
+
checkUnused,
|
|
80814
|
+
strictNullChecks
|
|
80815
|
+
);
|
|
80784
80816
|
}
|
|
80785
80817
|
if (!node.isDeclarationFile) {
|
|
80786
80818
|
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
80787
80819
|
}
|
|
80788
80820
|
});
|
|
80789
|
-
addLazyDiagnostic(() => {
|
|
80790
|
-
function isVisibleExternally(elem) {
|
|
80791
|
-
if (isOmittedExpression(elem)) {
|
|
80792
|
-
return false;
|
|
80793
|
-
}
|
|
80794
|
-
if (isBindingPattern(elem.name)) {
|
|
80795
|
-
return some(elem.name.elements, isVisibleExternally);
|
|
80796
|
-
} else {
|
|
80797
|
-
return isDeclarationVisible(elem);
|
|
80798
|
-
}
|
|
80799
|
-
}
|
|
80800
|
-
for (const [node2, type, widenedLiteralType] of ambiguousVariableDeclarationsWhenWidened) {
|
|
80801
|
-
if (isVisibleExternally(node2)) {
|
|
80802
|
-
error(node2.name, Diagnostics.The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1, typeToString(widenedLiteralType), typeToString(type));
|
|
80803
|
-
}
|
|
80804
|
-
}
|
|
80805
|
-
});
|
|
80806
80821
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !node.isDeclarationFile && isExternalModule(node)) {
|
|
80807
80822
|
checkImportsForTypeOnlyConversion(node);
|
|
80808
80823
|
}
|
|
@@ -80825,9 +80840,6 @@ function createTypeChecker(host) {
|
|
|
80825
80840
|
forEach(potentialReflectCollisions, checkReflectCollision);
|
|
80826
80841
|
clear(potentialReflectCollisions);
|
|
80827
80842
|
}
|
|
80828
|
-
if (ambiguousVariableDeclarationsWhenWidened.length) {
|
|
80829
|
-
clear(ambiguousVariableDeclarationsWhenWidened);
|
|
80830
|
-
}
|
|
80831
80843
|
links.flags |= 1 /* TypeChecked */;
|
|
80832
80844
|
}
|
|
80833
80845
|
}
|
package/lib/tsserver.js
CHANGED
|
@@ -10181,7 +10181,6 @@ var Diagnostics = {
|
|
|
10181
10181
|
Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
|
|
10182
10182
|
Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
|
|
10183
10183
|
Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
|
|
10184
|
-
The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1: diag(2860, 1 /* Error */, "The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1_2860", "The type of this declaration is ambiguous and may be observed as either '{0}' or '{1}'."),
|
|
10185
10184
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
10186
10185
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
10187
10186
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -19922,6 +19921,9 @@ function accessKind(node) {
|
|
|
19922
19921
|
return node === parent2.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent2.parent);
|
|
19923
19922
|
case 209 /* ArrayLiteralExpression */:
|
|
19924
19923
|
return accessKind(parent2);
|
|
19924
|
+
case 249 /* ForInStatement */:
|
|
19925
|
+
case 250 /* ForOfStatement */:
|
|
19926
|
+
return node === parent2.initializer ? 1 /* Write */ : 0 /* Read */;
|
|
19925
19927
|
default:
|
|
19926
19928
|
return 0 /* Read */;
|
|
19927
19929
|
}
|
|
@@ -48239,11 +48241,16 @@ function createTypeChecker(host) {
|
|
|
48239
48241
|
checkSourceFileWithEagerDiagnostics(file);
|
|
48240
48242
|
Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
48241
48243
|
diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
48242
|
-
|
|
48243
|
-
|
|
48244
|
-
|
|
48245
|
-
|
|
48246
|
-
|
|
48244
|
+
checkUnusedOrUninitializedIdentifiers(
|
|
48245
|
+
getPotentiallyUnusedOrUninitializedIdentifiers(file),
|
|
48246
|
+
(containingNode, kind, diag2) => {
|
|
48247
|
+
if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
|
|
48248
|
+
(diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
|
|
48249
|
+
}
|
|
48250
|
+
},
|
|
48251
|
+
/*checkUnused*/
|
|
48252
|
+
true
|
|
48253
|
+
);
|
|
48247
48254
|
return diagnostics2 || emptyArray;
|
|
48248
48255
|
} finally {
|
|
48249
48256
|
cancellationToken = void 0;
|
|
@@ -48740,7 +48747,7 @@ function createTypeChecker(host) {
|
|
|
48740
48747
|
var deferredGlobalClassAccessorDecoratorTargetType;
|
|
48741
48748
|
var deferredGlobalClassAccessorDecoratorResultType;
|
|
48742
48749
|
var deferredGlobalClassFieldDecoratorContextType;
|
|
48743
|
-
var
|
|
48750
|
+
var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
|
|
48744
48751
|
var flowLoopStart = 0;
|
|
48745
48752
|
var flowLoopCount = 0;
|
|
48746
48753
|
var sharedFlowCount = 0;
|
|
@@ -48783,7 +48790,6 @@ function createTypeChecker(host) {
|
|
|
48783
48790
|
var potentialReflectCollisions = [];
|
|
48784
48791
|
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
48785
48792
|
var awaitedTypeStack = [];
|
|
48786
|
-
var ambiguousVariableDeclarationsWhenWidened = [];
|
|
48787
48793
|
var diagnostics = createDiagnosticCollection();
|
|
48788
48794
|
var suggestionDiagnostics = createDiagnosticCollection();
|
|
48789
48795
|
var typeofType = createTypeofType();
|
|
@@ -49452,10 +49458,10 @@ function createTypeChecker(host) {
|
|
|
49452
49458
|
function isConstAssertion(location) {
|
|
49453
49459
|
return isAssertionExpression(location) && isConstTypeReference(location.type) || isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression);
|
|
49454
49460
|
}
|
|
49455
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true) {
|
|
49456
|
-
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol2);
|
|
49461
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true, isWritten = false) {
|
|
49462
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, getSymbol2);
|
|
49457
49463
|
}
|
|
49458
|
-
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
49464
|
+
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, lookup) {
|
|
49459
49465
|
var _a, _b, _c;
|
|
49460
49466
|
const originalLocation = location;
|
|
49461
49467
|
let result;
|
|
@@ -49681,6 +49687,9 @@ function createTypeChecker(host) {
|
|
|
49681
49687
|
if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
|
|
49682
49688
|
result.isReferenced |= meaning;
|
|
49683
49689
|
}
|
|
49690
|
+
if (isWritten && result) {
|
|
49691
|
+
result.isAssigned = true;
|
|
49692
|
+
}
|
|
49684
49693
|
if (!result) {
|
|
49685
49694
|
if (lastLocation) {
|
|
49686
49695
|
Debug.assertNode(lastLocation, isSourceFile);
|
|
@@ -69188,7 +69197,10 @@ function createTypeChecker(host) {
|
|
|
69188
69197
|
node,
|
|
69189
69198
|
!isWriteOnlyAccess(node),
|
|
69190
69199
|
/*excludeGlobals*/
|
|
69191
|
-
false
|
|
69200
|
+
false,
|
|
69201
|
+
/*getSpellingSuggestions*/
|
|
69202
|
+
void 0,
|
|
69203
|
+
isWriteAccess(node)
|
|
69192
69204
|
) || unknownSymbol;
|
|
69193
69205
|
}
|
|
69194
69206
|
return links.resolvedSymbol;
|
|
@@ -74622,6 +74634,8 @@ function createTypeChecker(host) {
|
|
|
74622
74634
|
false,
|
|
74623
74635
|
/*getSpellingSuggestions*/
|
|
74624
74636
|
true,
|
|
74637
|
+
/*isWritten*/
|
|
74638
|
+
false,
|
|
74625
74639
|
(symbols, name, meaning2) => {
|
|
74626
74640
|
Debug.assertEqual(outerName, name, "name should equal outerName");
|
|
74627
74641
|
const symbol = getSymbol2(symbols, name, meaning2);
|
|
@@ -80076,7 +80090,7 @@ function createTypeChecker(host) {
|
|
|
80076
80090
|
}
|
|
80077
80091
|
}
|
|
80078
80092
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
80079
|
-
|
|
80093
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
80080
80094
|
}
|
|
80081
80095
|
}
|
|
80082
80096
|
}
|
|
@@ -80621,7 +80635,7 @@ function createTypeChecker(host) {
|
|
|
80621
80635
|
}
|
|
80622
80636
|
}
|
|
80623
80637
|
}
|
|
80624
|
-
|
|
80638
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
80625
80639
|
}
|
|
80626
80640
|
function checkTemplateLiteralType(node) {
|
|
80627
80641
|
for (const span of node.templateSpans) {
|
|
@@ -81607,25 +81621,27 @@ function createTypeChecker(host) {
|
|
|
81607
81621
|
}
|
|
81608
81622
|
}
|
|
81609
81623
|
}
|
|
81610
|
-
function
|
|
81611
|
-
addLazyDiagnostic(
|
|
81612
|
-
function
|
|
81624
|
+
function registerForUnusedOrUninitializedIdentifiersCheck(node) {
|
|
81625
|
+
addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
|
|
81626
|
+
function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
|
|
81613
81627
|
const sourceFile = getSourceFileOfNode(node);
|
|
81614
|
-
let
|
|
81615
|
-
if (!
|
|
81616
|
-
|
|
81617
|
-
|
|
81628
|
+
let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
|
|
81629
|
+
if (!potentiallyUnusedOrUninitializedIdentifiers) {
|
|
81630
|
+
potentiallyUnusedOrUninitializedIdentifiers = [];
|
|
81631
|
+
allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
|
|
81618
81632
|
}
|
|
81619
|
-
|
|
81633
|
+
potentiallyUnusedOrUninitializedIdentifiers.push(node);
|
|
81620
81634
|
}
|
|
81621
81635
|
}
|
|
81622
|
-
function
|
|
81636
|
+
function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
|
|
81623
81637
|
for (const node of potentiallyUnusedIdentifiers) {
|
|
81624
81638
|
switch (node.kind) {
|
|
81625
81639
|
case 263 /* ClassDeclaration */:
|
|
81626
81640
|
case 231 /* ClassExpression */:
|
|
81627
|
-
|
|
81628
|
-
|
|
81641
|
+
if (checkUnused) {
|
|
81642
|
+
checkUnusedClassMembers(node, addDiagnostic);
|
|
81643
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
81644
|
+
}
|
|
81629
81645
|
break;
|
|
81630
81646
|
case 312 /* SourceFile */:
|
|
81631
81647
|
case 267 /* ModuleDeclaration */:
|
|
@@ -81634,7 +81650,12 @@ function createTypeChecker(host) {
|
|
|
81634
81650
|
case 248 /* ForStatement */:
|
|
81635
81651
|
case 249 /* ForInStatement */:
|
|
81636
81652
|
case 250 /* ForOfStatement */:
|
|
81637
|
-
|
|
81653
|
+
if (checkUnused) {
|
|
81654
|
+
checkUnusedLocalsAndParameters(node, addDiagnostic);
|
|
81655
|
+
}
|
|
81656
|
+
if (checkUninitialized) {
|
|
81657
|
+
checkUninitializedLocals(node);
|
|
81658
|
+
}
|
|
81638
81659
|
break;
|
|
81639
81660
|
case 176 /* Constructor */:
|
|
81640
81661
|
case 218 /* FunctionExpression */:
|
|
@@ -81643,10 +81664,15 @@ function createTypeChecker(host) {
|
|
|
81643
81664
|
case 174 /* MethodDeclaration */:
|
|
81644
81665
|
case 177 /* GetAccessor */:
|
|
81645
81666
|
case 178 /* SetAccessor */:
|
|
81646
|
-
if (
|
|
81647
|
-
|
|
81667
|
+
if (checkUnused) {
|
|
81668
|
+
if (node.body) {
|
|
81669
|
+
checkUnusedLocalsAndParameters(node, addDiagnostic);
|
|
81670
|
+
}
|
|
81671
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
81672
|
+
}
|
|
81673
|
+
if (checkUninitialized) {
|
|
81674
|
+
checkUninitializedLocals(node);
|
|
81648
81675
|
}
|
|
81649
|
-
checkUnusedTypeParameters(node, addDiagnostic);
|
|
81650
81676
|
break;
|
|
81651
81677
|
case 173 /* MethodSignature */:
|
|
81652
81678
|
case 179 /* CallSignature */:
|
|
@@ -81655,10 +81681,14 @@ function createTypeChecker(host) {
|
|
|
81655
81681
|
case 185 /* ConstructorType */:
|
|
81656
81682
|
case 265 /* TypeAliasDeclaration */:
|
|
81657
81683
|
case 264 /* InterfaceDeclaration */:
|
|
81658
|
-
|
|
81684
|
+
if (checkUnused) {
|
|
81685
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
81686
|
+
}
|
|
81659
81687
|
break;
|
|
81660
81688
|
case 195 /* InferType */:
|
|
81661
|
-
|
|
81689
|
+
if (checkUnused) {
|
|
81690
|
+
checkUnusedInferTypeParameter(node, addDiagnostic);
|
|
81691
|
+
}
|
|
81662
81692
|
break;
|
|
81663
81693
|
default:
|
|
81664
81694
|
Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
|
|
@@ -81848,6 +81878,26 @@ function createTypeChecker(host) {
|
|
|
81848
81878
|
}
|
|
81849
81879
|
});
|
|
81850
81880
|
}
|
|
81881
|
+
function checkUninitializedLocals(nodeWithLocals) {
|
|
81882
|
+
nodeWithLocals.locals.forEach((local) => {
|
|
81883
|
+
if (!(local.flags & 3 /* Variable */) || local.isAssigned || !local.isReferenced) {
|
|
81884
|
+
return;
|
|
81885
|
+
}
|
|
81886
|
+
const declaration = local.valueDeclaration;
|
|
81887
|
+
if (!declaration) {
|
|
81888
|
+
return;
|
|
81889
|
+
}
|
|
81890
|
+
if (isVariableDeclaration(declaration)) {
|
|
81891
|
+
if (getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
|
|
81892
|
+
return;
|
|
81893
|
+
}
|
|
81894
|
+
const type = getTypeFromTypeNode(declaration.type);
|
|
81895
|
+
if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
|
|
81896
|
+
error2(declaration, Diagnostics.Variable_0_is_used_before_being_assigned, idText(declaration.name));
|
|
81897
|
+
}
|
|
81898
|
+
}
|
|
81899
|
+
});
|
|
81900
|
+
}
|
|
81851
81901
|
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
81852
81902
|
var _a;
|
|
81853
81903
|
for (const node of potentialUnusedRenamedBindingElementsInTypes) {
|
|
@@ -81894,7 +81944,7 @@ function createTypeChecker(host) {
|
|
|
81894
81944
|
forEach(node.statements, checkSourceElement);
|
|
81895
81945
|
}
|
|
81896
81946
|
if (node.locals) {
|
|
81897
|
-
|
|
81947
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
81898
81948
|
}
|
|
81899
81949
|
}
|
|
81900
81950
|
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
|
@@ -82243,29 +82293,6 @@ function createTypeChecker(host) {
|
|
|
82243
82293
|
}
|
|
82244
82294
|
checkCollisionsForDeclarationName(node, node.name);
|
|
82245
82295
|
}
|
|
82246
|
-
function canHaveLiteralInitializer2(node2) {
|
|
82247
|
-
switch (node2.kind) {
|
|
82248
|
-
case 172 /* PropertyDeclaration */:
|
|
82249
|
-
case 171 /* PropertySignature */:
|
|
82250
|
-
return !hasEffectiveModifier(node2, 8 /* Private */);
|
|
82251
|
-
case 169 /* Parameter */:
|
|
82252
|
-
case 260 /* VariableDeclaration */:
|
|
82253
|
-
return true;
|
|
82254
|
-
}
|
|
82255
|
-
return false;
|
|
82256
|
-
}
|
|
82257
|
-
function shouldPrintWithInitializer(node2) {
|
|
82258
|
-
return canHaveLiteralInitializer2(node2) && isLiteralConstDeclaration(node2);
|
|
82259
|
-
}
|
|
82260
|
-
function isPrivateDeclaration(node2) {
|
|
82261
|
-
return hasEffectiveModifier(node2, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(node2);
|
|
82262
|
-
}
|
|
82263
|
-
if (getEmitDeclarations(compilerOptions) && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) && !shouldPrintWithInitializer(node) && !isPrivateDeclaration(node)) {
|
|
82264
|
-
const widenedLiteralType = getWidenedLiteralType(type);
|
|
82265
|
-
if (!isTypeIdenticalTo(type, widenedLiteralType)) {
|
|
82266
|
-
ambiguousVariableDeclarationsWhenWidened.push([node, type, widenedLiteralType]);
|
|
82267
|
-
}
|
|
82268
|
-
}
|
|
82269
82296
|
}
|
|
82270
82297
|
function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
|
|
82271
82298
|
const nextDeclarationName = getNameOfDeclaration(nextDeclaration);
|
|
@@ -82467,7 +82494,7 @@ function createTypeChecker(host) {
|
|
|
82467
82494
|
checkExpression(node.incrementor);
|
|
82468
82495
|
checkSourceElement(node.statement);
|
|
82469
82496
|
if (node.locals) {
|
|
82470
|
-
|
|
82497
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
82471
82498
|
}
|
|
82472
82499
|
}
|
|
82473
82500
|
function checkForOfStatement(node) {
|
|
@@ -82506,7 +82533,7 @@ function createTypeChecker(host) {
|
|
|
82506
82533
|
}
|
|
82507
82534
|
checkSourceElement(node.statement);
|
|
82508
82535
|
if (node.locals) {
|
|
82509
|
-
|
|
82536
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
82510
82537
|
}
|
|
82511
82538
|
}
|
|
82512
82539
|
function checkForInStatement(node) {
|
|
@@ -82538,7 +82565,7 @@ function createTypeChecker(host) {
|
|
|
82538
82565
|
}
|
|
82539
82566
|
checkSourceElement(node.statement);
|
|
82540
82567
|
if (node.locals) {
|
|
82541
|
-
|
|
82568
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
82542
82569
|
}
|
|
82543
82570
|
}
|
|
82544
82571
|
function checkRightHandSideOfForOf(statement) {
|
|
@@ -83270,7 +83297,7 @@ function createTypeChecker(host) {
|
|
|
83270
83297
|
}
|
|
83271
83298
|
});
|
|
83272
83299
|
if (node.caseBlock.locals) {
|
|
83273
|
-
|
|
83300
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
|
|
83274
83301
|
}
|
|
83275
83302
|
}
|
|
83276
83303
|
function checkLabeledStatement(node) {
|
|
@@ -83610,7 +83637,7 @@ function createTypeChecker(host) {
|
|
|
83610
83637
|
}
|
|
83611
83638
|
function checkClassExpressionDeferred(node) {
|
|
83612
83639
|
forEach(node.members, checkSourceElement);
|
|
83613
|
-
|
|
83640
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
83614
83641
|
}
|
|
83615
83642
|
function checkClassDeclaration(node) {
|
|
83616
83643
|
const firstDecorator = find(node.modifiers, isDecorator);
|
|
@@ -83622,7 +83649,7 @@ function createTypeChecker(host) {
|
|
|
83622
83649
|
}
|
|
83623
83650
|
checkClassLikeDeclaration(node);
|
|
83624
83651
|
forEach(node.members, checkSourceElement);
|
|
83625
|
-
|
|
83652
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
83626
83653
|
}
|
|
83627
83654
|
function checkClassLikeDeclaration(node) {
|
|
83628
83655
|
checkGrammarClassLikeDeclaration(node);
|
|
@@ -84183,7 +84210,7 @@ function createTypeChecker(host) {
|
|
|
84183
84210
|
forEach(node.members, checkSourceElement);
|
|
84184
84211
|
addLazyDiagnostic(() => {
|
|
84185
84212
|
checkTypeForDuplicateIndexSignatures(node);
|
|
84186
|
-
|
|
84213
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
84187
84214
|
});
|
|
84188
84215
|
}
|
|
84189
84216
|
function checkTypeAliasDeclaration(node) {
|
|
@@ -84197,7 +84224,7 @@ function createTypeChecker(host) {
|
|
|
84197
84224
|
}
|
|
84198
84225
|
} else {
|
|
84199
84226
|
checkSourceElement(node.type);
|
|
84200
|
-
|
|
84227
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
84201
84228
|
}
|
|
84202
84229
|
}
|
|
84203
84230
|
function computeEnumMemberValues(node) {
|
|
@@ -84468,7 +84495,7 @@ function createTypeChecker(host) {
|
|
|
84468
84495
|
if (node.body) {
|
|
84469
84496
|
checkSourceElement(node.body);
|
|
84470
84497
|
if (!isGlobalScopeAugmentation(node)) {
|
|
84471
|
-
|
|
84498
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
84472
84499
|
}
|
|
84473
84500
|
}
|
|
84474
84501
|
addLazyDiagnostic(checkModuleDeclarationDiagnostics);
|
|
@@ -85466,8 +85493,8 @@ function createTypeChecker(host) {
|
|
|
85466
85493
|
return Debug.assertNever(kind);
|
|
85467
85494
|
}
|
|
85468
85495
|
}
|
|
85469
|
-
function
|
|
85470
|
-
return
|
|
85496
|
+
function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
|
|
85497
|
+
return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
|
|
85471
85498
|
}
|
|
85472
85499
|
function checkSourceFileWorker(node) {
|
|
85473
85500
|
const links = getNodeLinks(node);
|
|
@@ -85481,42 +85508,30 @@ function createTypeChecker(host) {
|
|
|
85481
85508
|
clear(potentialWeakMapSetCollisions);
|
|
85482
85509
|
clear(potentialReflectCollisions);
|
|
85483
85510
|
clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
85484
|
-
clear(ambiguousVariableDeclarationsWhenWidened);
|
|
85485
85511
|
forEach(node.statements, checkSourceElement);
|
|
85486
85512
|
checkSourceElement(node.endOfFileToken);
|
|
85487
85513
|
checkDeferredNodes(node);
|
|
85488
85514
|
if (isExternalOrCommonJsModule(node)) {
|
|
85489
|
-
|
|
85515
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
85490
85516
|
}
|
|
85491
85517
|
addLazyDiagnostic(() => {
|
|
85492
|
-
|
|
85493
|
-
|
|
85494
|
-
|
|
85495
|
-
|
|
85496
|
-
|
|
85497
|
-
|
|
85518
|
+
const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
|
|
85519
|
+
if (checkUnused || strictNullChecks) {
|
|
85520
|
+
checkUnusedOrUninitializedIdentifiers(
|
|
85521
|
+
getPotentiallyUnusedOrUninitializedIdentifiers(node),
|
|
85522
|
+
(containingNode, kind, diag2) => {
|
|
85523
|
+
if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
|
|
85524
|
+
diagnostics.add(diag2);
|
|
85525
|
+
}
|
|
85526
|
+
},
|
|
85527
|
+
checkUnused,
|
|
85528
|
+
strictNullChecks
|
|
85529
|
+
);
|
|
85498
85530
|
}
|
|
85499
85531
|
if (!node.isDeclarationFile) {
|
|
85500
85532
|
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
85501
85533
|
}
|
|
85502
85534
|
});
|
|
85503
|
-
addLazyDiagnostic(() => {
|
|
85504
|
-
function isVisibleExternally(elem) {
|
|
85505
|
-
if (isOmittedExpression(elem)) {
|
|
85506
|
-
return false;
|
|
85507
|
-
}
|
|
85508
|
-
if (isBindingPattern(elem.name)) {
|
|
85509
|
-
return some(elem.name.elements, isVisibleExternally);
|
|
85510
|
-
} else {
|
|
85511
|
-
return isDeclarationVisible(elem);
|
|
85512
|
-
}
|
|
85513
|
-
}
|
|
85514
|
-
for (const [node2, type, widenedLiteralType] of ambiguousVariableDeclarationsWhenWidened) {
|
|
85515
|
-
if (isVisibleExternally(node2)) {
|
|
85516
|
-
error2(node2.name, Diagnostics.The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1, typeToString(widenedLiteralType), typeToString(type));
|
|
85517
|
-
}
|
|
85518
|
-
}
|
|
85519
|
-
});
|
|
85520
85535
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !node.isDeclarationFile && isExternalModule(node)) {
|
|
85521
85536
|
checkImportsForTypeOnlyConversion(node);
|
|
85522
85537
|
}
|
|
@@ -85539,9 +85554,6 @@ function createTypeChecker(host) {
|
|
|
85539
85554
|
forEach(potentialReflectCollisions, checkReflectCollision);
|
|
85540
85555
|
clear(potentialReflectCollisions);
|
|
85541
85556
|
}
|
|
85542
|
-
if (ambiguousVariableDeclarationsWhenWidened.length) {
|
|
85543
|
-
clear(ambiguousVariableDeclarationsWhenWidened);
|
|
85544
|
-
}
|
|
85545
85557
|
links.flags |= 1 /* TypeChecked */;
|
|
85546
85558
|
}
|
|
85547
85559
|
}
|
package/lib/typescript.js
CHANGED
|
@@ -7961,7 +7961,6 @@ ${lanes.join("\n")}
|
|
|
7961
7961
|
Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
|
|
7962
7962
|
Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
|
|
7963
7963
|
Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
|
|
7964
|
-
The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1: diag(2860, 1 /* Error */, "The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1_2860", "The type of this declaration is ambiguous and may be observed as either '{0}' or '{1}'."),
|
|
7965
7964
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
7966
7965
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
7967
7966
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -17221,6 +17220,9 @@ ${lanes.join("\n")}
|
|
|
17221
17220
|
return node === parent2.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent2.parent);
|
|
17222
17221
|
case 209 /* ArrayLiteralExpression */:
|
|
17223
17222
|
return accessKind(parent2);
|
|
17223
|
+
case 249 /* ForInStatement */:
|
|
17224
|
+
case 250 /* ForOfStatement */:
|
|
17225
|
+
return node === parent2.initializer ? 1 /* Write */ : 0 /* Read */;
|
|
17224
17226
|
default:
|
|
17225
17227
|
return 0 /* Read */;
|
|
17226
17228
|
}
|
|
@@ -46003,11 +46005,16 @@ ${lanes.join("\n")}
|
|
|
46003
46005
|
checkSourceFileWithEagerDiagnostics(file);
|
|
46004
46006
|
Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
46005
46007
|
diagnostics2 = addRange(diagnostics2, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
46006
|
-
|
|
46007
|
-
|
|
46008
|
-
|
|
46009
|
-
|
|
46010
|
-
|
|
46008
|
+
checkUnusedOrUninitializedIdentifiers(
|
|
46009
|
+
getPotentiallyUnusedOrUninitializedIdentifiers(file),
|
|
46010
|
+
(containingNode, kind, diag2) => {
|
|
46011
|
+
if (!containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
|
|
46012
|
+
(diagnostics2 || (diagnostics2 = [])).push({ ...diag2, category: 2 /* Suggestion */ });
|
|
46013
|
+
}
|
|
46014
|
+
},
|
|
46015
|
+
/*checkUnused*/
|
|
46016
|
+
true
|
|
46017
|
+
);
|
|
46011
46018
|
return diagnostics2 || emptyArray;
|
|
46012
46019
|
} finally {
|
|
46013
46020
|
cancellationToken = void 0;
|
|
@@ -46504,7 +46511,7 @@ ${lanes.join("\n")}
|
|
|
46504
46511
|
var deferredGlobalClassAccessorDecoratorTargetType;
|
|
46505
46512
|
var deferredGlobalClassAccessorDecoratorResultType;
|
|
46506
46513
|
var deferredGlobalClassFieldDecoratorContextType;
|
|
46507
|
-
var
|
|
46514
|
+
var allPotentiallyUnusedOrUninitializedIdentifiers = /* @__PURE__ */ new Map();
|
|
46508
46515
|
var flowLoopStart = 0;
|
|
46509
46516
|
var flowLoopCount = 0;
|
|
46510
46517
|
var sharedFlowCount = 0;
|
|
@@ -46547,7 +46554,6 @@ ${lanes.join("\n")}
|
|
|
46547
46554
|
var potentialReflectCollisions = [];
|
|
46548
46555
|
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
46549
46556
|
var awaitedTypeStack = [];
|
|
46550
|
-
var ambiguousVariableDeclarationsWhenWidened = [];
|
|
46551
46557
|
var diagnostics = createDiagnosticCollection();
|
|
46552
46558
|
var suggestionDiagnostics = createDiagnosticCollection();
|
|
46553
46559
|
var typeofType = createTypeofType();
|
|
@@ -47216,10 +47222,10 @@ ${lanes.join("\n")}
|
|
|
47216
47222
|
function isConstAssertion(location) {
|
|
47217
47223
|
return isAssertionExpression(location) && isConstTypeReference(location.type) || isJSDocTypeTag(location) && isConstTypeReference(location.typeExpression);
|
|
47218
47224
|
}
|
|
47219
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true) {
|
|
47220
|
-
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol2);
|
|
47225
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals = false, getSpellingSuggestions = true, isWritten = false) {
|
|
47226
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, getSymbol2);
|
|
47221
47227
|
}
|
|
47222
|
-
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
47228
|
+
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, isWritten, lookup) {
|
|
47223
47229
|
var _a, _b, _c;
|
|
47224
47230
|
const originalLocation = location;
|
|
47225
47231
|
let result;
|
|
@@ -47445,6 +47451,9 @@ ${lanes.join("\n")}
|
|
|
47445
47451
|
if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
|
|
47446
47452
|
result.isReferenced |= meaning;
|
|
47447
47453
|
}
|
|
47454
|
+
if (isWritten && result) {
|
|
47455
|
+
result.isAssigned = true;
|
|
47456
|
+
}
|
|
47448
47457
|
if (!result) {
|
|
47449
47458
|
if (lastLocation) {
|
|
47450
47459
|
Debug.assertNode(lastLocation, isSourceFile);
|
|
@@ -66952,7 +66961,10 @@ ${lanes.join("\n")}
|
|
|
66952
66961
|
node,
|
|
66953
66962
|
!isWriteOnlyAccess(node),
|
|
66954
66963
|
/*excludeGlobals*/
|
|
66955
|
-
false
|
|
66964
|
+
false,
|
|
66965
|
+
/*getSpellingSuggestions*/
|
|
66966
|
+
void 0,
|
|
66967
|
+
isWriteAccess(node)
|
|
66956
66968
|
) || unknownSymbol;
|
|
66957
66969
|
}
|
|
66958
66970
|
return links.resolvedSymbol;
|
|
@@ -72386,6 +72398,8 @@ ${lanes.join("\n")}
|
|
|
72386
72398
|
false,
|
|
72387
72399
|
/*getSpellingSuggestions*/
|
|
72388
72400
|
true,
|
|
72401
|
+
/*isWritten*/
|
|
72402
|
+
false,
|
|
72389
72403
|
(symbols, name, meaning2) => {
|
|
72390
72404
|
Debug.assertEqual(outerName, name, "name should equal outerName");
|
|
72391
72405
|
const symbol = getSymbol2(symbols, name, meaning2);
|
|
@@ -77840,7 +77854,7 @@ ${lanes.join("\n")}
|
|
|
77840
77854
|
}
|
|
77841
77855
|
}
|
|
77842
77856
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
77843
|
-
|
|
77857
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
77844
77858
|
}
|
|
77845
77859
|
}
|
|
77846
77860
|
}
|
|
@@ -78385,7 +78399,7 @@ ${lanes.join("\n")}
|
|
|
78385
78399
|
}
|
|
78386
78400
|
}
|
|
78387
78401
|
}
|
|
78388
|
-
|
|
78402
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
78389
78403
|
}
|
|
78390
78404
|
function checkTemplateLiteralType(node) {
|
|
78391
78405
|
for (const span of node.templateSpans) {
|
|
@@ -79371,25 +79385,27 @@ ${lanes.join("\n")}
|
|
|
79371
79385
|
}
|
|
79372
79386
|
}
|
|
79373
79387
|
}
|
|
79374
|
-
function
|
|
79375
|
-
addLazyDiagnostic(
|
|
79376
|
-
function
|
|
79388
|
+
function registerForUnusedOrUninitializedIdentifiersCheck(node) {
|
|
79389
|
+
addLazyDiagnostic(registerForUnusedOrUninitializedIdentifiersCheckDiagnostics);
|
|
79390
|
+
function registerForUnusedOrUninitializedIdentifiersCheckDiagnostics() {
|
|
79377
79391
|
const sourceFile = getSourceFileOfNode(node);
|
|
79378
|
-
let
|
|
79379
|
-
if (!
|
|
79380
|
-
|
|
79381
|
-
|
|
79392
|
+
let potentiallyUnusedOrUninitializedIdentifiers = allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path);
|
|
79393
|
+
if (!potentiallyUnusedOrUninitializedIdentifiers) {
|
|
79394
|
+
potentiallyUnusedOrUninitializedIdentifiers = [];
|
|
79395
|
+
allPotentiallyUnusedOrUninitializedIdentifiers.set(sourceFile.path, potentiallyUnusedOrUninitializedIdentifiers);
|
|
79382
79396
|
}
|
|
79383
|
-
|
|
79397
|
+
potentiallyUnusedOrUninitializedIdentifiers.push(node);
|
|
79384
79398
|
}
|
|
79385
79399
|
}
|
|
79386
|
-
function
|
|
79400
|
+
function checkUnusedOrUninitializedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic, checkUnused, checkUninitialized) {
|
|
79387
79401
|
for (const node of potentiallyUnusedIdentifiers) {
|
|
79388
79402
|
switch (node.kind) {
|
|
79389
79403
|
case 263 /* ClassDeclaration */:
|
|
79390
79404
|
case 231 /* ClassExpression */:
|
|
79391
|
-
|
|
79392
|
-
|
|
79405
|
+
if (checkUnused) {
|
|
79406
|
+
checkUnusedClassMembers(node, addDiagnostic);
|
|
79407
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
79408
|
+
}
|
|
79393
79409
|
break;
|
|
79394
79410
|
case 312 /* SourceFile */:
|
|
79395
79411
|
case 267 /* ModuleDeclaration */:
|
|
@@ -79398,7 +79414,12 @@ ${lanes.join("\n")}
|
|
|
79398
79414
|
case 248 /* ForStatement */:
|
|
79399
79415
|
case 249 /* ForInStatement */:
|
|
79400
79416
|
case 250 /* ForOfStatement */:
|
|
79401
|
-
|
|
79417
|
+
if (checkUnused) {
|
|
79418
|
+
checkUnusedLocalsAndParameters(node, addDiagnostic);
|
|
79419
|
+
}
|
|
79420
|
+
if (checkUninitialized) {
|
|
79421
|
+
checkUninitializedLocals(node);
|
|
79422
|
+
}
|
|
79402
79423
|
break;
|
|
79403
79424
|
case 176 /* Constructor */:
|
|
79404
79425
|
case 218 /* FunctionExpression */:
|
|
@@ -79407,10 +79428,15 @@ ${lanes.join("\n")}
|
|
|
79407
79428
|
case 174 /* MethodDeclaration */:
|
|
79408
79429
|
case 177 /* GetAccessor */:
|
|
79409
79430
|
case 178 /* SetAccessor */:
|
|
79410
|
-
if (
|
|
79411
|
-
|
|
79431
|
+
if (checkUnused) {
|
|
79432
|
+
if (node.body) {
|
|
79433
|
+
checkUnusedLocalsAndParameters(node, addDiagnostic);
|
|
79434
|
+
}
|
|
79435
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
79436
|
+
}
|
|
79437
|
+
if (checkUninitialized) {
|
|
79438
|
+
checkUninitializedLocals(node);
|
|
79412
79439
|
}
|
|
79413
|
-
checkUnusedTypeParameters(node, addDiagnostic);
|
|
79414
79440
|
break;
|
|
79415
79441
|
case 173 /* MethodSignature */:
|
|
79416
79442
|
case 179 /* CallSignature */:
|
|
@@ -79419,10 +79445,14 @@ ${lanes.join("\n")}
|
|
|
79419
79445
|
case 185 /* ConstructorType */:
|
|
79420
79446
|
case 265 /* TypeAliasDeclaration */:
|
|
79421
79447
|
case 264 /* InterfaceDeclaration */:
|
|
79422
|
-
|
|
79448
|
+
if (checkUnused) {
|
|
79449
|
+
checkUnusedTypeParameters(node, addDiagnostic);
|
|
79450
|
+
}
|
|
79423
79451
|
break;
|
|
79424
79452
|
case 195 /* InferType */:
|
|
79425
|
-
|
|
79453
|
+
if (checkUnused) {
|
|
79454
|
+
checkUnusedInferTypeParameter(node, addDiagnostic);
|
|
79455
|
+
}
|
|
79426
79456
|
break;
|
|
79427
79457
|
default:
|
|
79428
79458
|
Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
|
|
@@ -79612,6 +79642,26 @@ ${lanes.join("\n")}
|
|
|
79612
79642
|
}
|
|
79613
79643
|
});
|
|
79614
79644
|
}
|
|
79645
|
+
function checkUninitializedLocals(nodeWithLocals) {
|
|
79646
|
+
nodeWithLocals.locals.forEach((local) => {
|
|
79647
|
+
if (!(local.flags & 3 /* Variable */) || local.isAssigned || !local.isReferenced) {
|
|
79648
|
+
return;
|
|
79649
|
+
}
|
|
79650
|
+
const declaration = local.valueDeclaration;
|
|
79651
|
+
if (!declaration) {
|
|
79652
|
+
return;
|
|
79653
|
+
}
|
|
79654
|
+
if (isVariableDeclaration(declaration)) {
|
|
79655
|
+
if (getCombinedNodeFlagsCached(declaration) & 33554432 /* Ambient */ || declaration.exclamationToken || declaration.initializer || !declaration.type) {
|
|
79656
|
+
return;
|
|
79657
|
+
}
|
|
79658
|
+
const type = getTypeFromTypeNode(declaration.type);
|
|
79659
|
+
if (!(type.flags & 3 /* AnyOrUnknown */) && !containsUndefinedType(type)) {
|
|
79660
|
+
error2(declaration, Diagnostics.Variable_0_is_used_before_being_assigned, idText(declaration.name));
|
|
79661
|
+
}
|
|
79662
|
+
}
|
|
79663
|
+
});
|
|
79664
|
+
}
|
|
79615
79665
|
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
79616
79666
|
var _a;
|
|
79617
79667
|
for (const node of potentialUnusedRenamedBindingElementsInTypes) {
|
|
@@ -79658,7 +79708,7 @@ ${lanes.join("\n")}
|
|
|
79658
79708
|
forEach(node.statements, checkSourceElement);
|
|
79659
79709
|
}
|
|
79660
79710
|
if (node.locals) {
|
|
79661
|
-
|
|
79711
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
79662
79712
|
}
|
|
79663
79713
|
}
|
|
79664
79714
|
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
|
@@ -80007,29 +80057,6 @@ ${lanes.join("\n")}
|
|
|
80007
80057
|
}
|
|
80008
80058
|
checkCollisionsForDeclarationName(node, node.name);
|
|
80009
80059
|
}
|
|
80010
|
-
function canHaveLiteralInitializer2(node2) {
|
|
80011
|
-
switch (node2.kind) {
|
|
80012
|
-
case 172 /* PropertyDeclaration */:
|
|
80013
|
-
case 171 /* PropertySignature */:
|
|
80014
|
-
return !hasEffectiveModifier(node2, 8 /* Private */);
|
|
80015
|
-
case 169 /* Parameter */:
|
|
80016
|
-
case 260 /* VariableDeclaration */:
|
|
80017
|
-
return true;
|
|
80018
|
-
}
|
|
80019
|
-
return false;
|
|
80020
|
-
}
|
|
80021
|
-
function shouldPrintWithInitializer(node2) {
|
|
80022
|
-
return canHaveLiteralInitializer2(node2) && isLiteralConstDeclaration(node2);
|
|
80023
|
-
}
|
|
80024
|
-
function isPrivateDeclaration(node2) {
|
|
80025
|
-
return hasEffectiveModifier(node2, 8 /* Private */) || isPrivateIdentifierClassElementDeclaration(node2);
|
|
80026
|
-
}
|
|
80027
|
-
if (getEmitDeclarations(compilerOptions) && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) && !shouldPrintWithInitializer(node) && !isPrivateDeclaration(node)) {
|
|
80028
|
-
const widenedLiteralType = getWidenedLiteralType(type);
|
|
80029
|
-
if (!isTypeIdenticalTo(type, widenedLiteralType)) {
|
|
80030
|
-
ambiguousVariableDeclarationsWhenWidened.push([node, type, widenedLiteralType]);
|
|
80031
|
-
}
|
|
80032
|
-
}
|
|
80033
80060
|
}
|
|
80034
80061
|
function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
|
|
80035
80062
|
const nextDeclarationName = getNameOfDeclaration(nextDeclaration);
|
|
@@ -80231,7 +80258,7 @@ ${lanes.join("\n")}
|
|
|
80231
80258
|
checkExpression(node.incrementor);
|
|
80232
80259
|
checkSourceElement(node.statement);
|
|
80233
80260
|
if (node.locals) {
|
|
80234
|
-
|
|
80261
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
80235
80262
|
}
|
|
80236
80263
|
}
|
|
80237
80264
|
function checkForOfStatement(node) {
|
|
@@ -80270,7 +80297,7 @@ ${lanes.join("\n")}
|
|
|
80270
80297
|
}
|
|
80271
80298
|
checkSourceElement(node.statement);
|
|
80272
80299
|
if (node.locals) {
|
|
80273
|
-
|
|
80300
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
80274
80301
|
}
|
|
80275
80302
|
}
|
|
80276
80303
|
function checkForInStatement(node) {
|
|
@@ -80302,7 +80329,7 @@ ${lanes.join("\n")}
|
|
|
80302
80329
|
}
|
|
80303
80330
|
checkSourceElement(node.statement);
|
|
80304
80331
|
if (node.locals) {
|
|
80305
|
-
|
|
80332
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
80306
80333
|
}
|
|
80307
80334
|
}
|
|
80308
80335
|
function checkRightHandSideOfForOf(statement) {
|
|
@@ -81034,7 +81061,7 @@ ${lanes.join("\n")}
|
|
|
81034
81061
|
}
|
|
81035
81062
|
});
|
|
81036
81063
|
if (node.caseBlock.locals) {
|
|
81037
|
-
|
|
81064
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node.caseBlock);
|
|
81038
81065
|
}
|
|
81039
81066
|
}
|
|
81040
81067
|
function checkLabeledStatement(node) {
|
|
@@ -81374,7 +81401,7 @@ ${lanes.join("\n")}
|
|
|
81374
81401
|
}
|
|
81375
81402
|
function checkClassExpressionDeferred(node) {
|
|
81376
81403
|
forEach(node.members, checkSourceElement);
|
|
81377
|
-
|
|
81404
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
81378
81405
|
}
|
|
81379
81406
|
function checkClassDeclaration(node) {
|
|
81380
81407
|
const firstDecorator = find(node.modifiers, isDecorator);
|
|
@@ -81386,7 +81413,7 @@ ${lanes.join("\n")}
|
|
|
81386
81413
|
}
|
|
81387
81414
|
checkClassLikeDeclaration(node);
|
|
81388
81415
|
forEach(node.members, checkSourceElement);
|
|
81389
|
-
|
|
81416
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
81390
81417
|
}
|
|
81391
81418
|
function checkClassLikeDeclaration(node) {
|
|
81392
81419
|
checkGrammarClassLikeDeclaration(node);
|
|
@@ -81947,7 +81974,7 @@ ${lanes.join("\n")}
|
|
|
81947
81974
|
forEach(node.members, checkSourceElement);
|
|
81948
81975
|
addLazyDiagnostic(() => {
|
|
81949
81976
|
checkTypeForDuplicateIndexSignatures(node);
|
|
81950
|
-
|
|
81977
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
81951
81978
|
});
|
|
81952
81979
|
}
|
|
81953
81980
|
function checkTypeAliasDeclaration(node) {
|
|
@@ -81961,7 +81988,7 @@ ${lanes.join("\n")}
|
|
|
81961
81988
|
}
|
|
81962
81989
|
} else {
|
|
81963
81990
|
checkSourceElement(node.type);
|
|
81964
|
-
|
|
81991
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
81965
81992
|
}
|
|
81966
81993
|
}
|
|
81967
81994
|
function computeEnumMemberValues(node) {
|
|
@@ -82232,7 +82259,7 @@ ${lanes.join("\n")}
|
|
|
82232
82259
|
if (node.body) {
|
|
82233
82260
|
checkSourceElement(node.body);
|
|
82234
82261
|
if (!isGlobalScopeAugmentation(node)) {
|
|
82235
|
-
|
|
82262
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
82236
82263
|
}
|
|
82237
82264
|
}
|
|
82238
82265
|
addLazyDiagnostic(checkModuleDeclarationDiagnostics);
|
|
@@ -83230,8 +83257,8 @@ ${lanes.join("\n")}
|
|
|
83230
83257
|
return Debug.assertNever(kind);
|
|
83231
83258
|
}
|
|
83232
83259
|
}
|
|
83233
|
-
function
|
|
83234
|
-
return
|
|
83260
|
+
function getPotentiallyUnusedOrUninitializedIdentifiers(sourceFile) {
|
|
83261
|
+
return allPotentiallyUnusedOrUninitializedIdentifiers.get(sourceFile.path) || emptyArray;
|
|
83235
83262
|
}
|
|
83236
83263
|
function checkSourceFileWorker(node) {
|
|
83237
83264
|
const links = getNodeLinks(node);
|
|
@@ -83245,42 +83272,30 @@ ${lanes.join("\n")}
|
|
|
83245
83272
|
clear(potentialWeakMapSetCollisions);
|
|
83246
83273
|
clear(potentialReflectCollisions);
|
|
83247
83274
|
clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
83248
|
-
clear(ambiguousVariableDeclarationsWhenWidened);
|
|
83249
83275
|
forEach(node.statements, checkSourceElement);
|
|
83250
83276
|
checkSourceElement(node.endOfFileToken);
|
|
83251
83277
|
checkDeferredNodes(node);
|
|
83252
83278
|
if (isExternalOrCommonJsModule(node)) {
|
|
83253
|
-
|
|
83279
|
+
registerForUnusedOrUninitializedIdentifiersCheck(node);
|
|
83254
83280
|
}
|
|
83255
83281
|
addLazyDiagnostic(() => {
|
|
83256
|
-
|
|
83257
|
-
|
|
83258
|
-
|
|
83259
|
-
|
|
83260
|
-
|
|
83261
|
-
|
|
83282
|
+
const checkUnused = !node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters);
|
|
83283
|
+
if (checkUnused || strictNullChecks) {
|
|
83284
|
+
checkUnusedOrUninitializedIdentifiers(
|
|
83285
|
+
getPotentiallyUnusedOrUninitializedIdentifiers(node),
|
|
83286
|
+
(containingNode, kind, diag2) => {
|
|
83287
|
+
if (!containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 33554432 /* Ambient */))) {
|
|
83288
|
+
diagnostics.add(diag2);
|
|
83289
|
+
}
|
|
83290
|
+
},
|
|
83291
|
+
checkUnused,
|
|
83292
|
+
strictNullChecks
|
|
83293
|
+
);
|
|
83262
83294
|
}
|
|
83263
83295
|
if (!node.isDeclarationFile) {
|
|
83264
83296
|
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
83265
83297
|
}
|
|
83266
83298
|
});
|
|
83267
|
-
addLazyDiagnostic(() => {
|
|
83268
|
-
function isVisibleExternally(elem) {
|
|
83269
|
-
if (isOmittedExpression(elem)) {
|
|
83270
|
-
return false;
|
|
83271
|
-
}
|
|
83272
|
-
if (isBindingPattern(elem.name)) {
|
|
83273
|
-
return some(elem.name.elements, isVisibleExternally);
|
|
83274
|
-
} else {
|
|
83275
|
-
return isDeclarationVisible(elem);
|
|
83276
|
-
}
|
|
83277
|
-
}
|
|
83278
|
-
for (const [node2, type, widenedLiteralType] of ambiguousVariableDeclarationsWhenWidened) {
|
|
83279
|
-
if (isVisibleExternally(node2)) {
|
|
83280
|
-
error2(node2.name, Diagnostics.The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1, typeToString(widenedLiteralType), typeToString(type));
|
|
83281
|
-
}
|
|
83282
|
-
}
|
|
83283
|
-
});
|
|
83284
83299
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !node.isDeclarationFile && isExternalModule(node)) {
|
|
83285
83300
|
checkImportsForTypeOnlyConversion(node);
|
|
83286
83301
|
}
|
|
@@ -83303,9 +83318,6 @@ ${lanes.join("\n")}
|
|
|
83303
83318
|
forEach(potentialReflectCollisions, checkReflectCollision);
|
|
83304
83319
|
clear(potentialReflectCollisions);
|
|
83305
83320
|
}
|
|
83306
|
-
if (ambiguousVariableDeclarationsWhenWidened.length) {
|
|
83307
|
-
clear(ambiguousVariableDeclarationsWhenWidened);
|
|
83308
|
-
}
|
|
83309
83321
|
links.flags |= 1 /* TypeChecked */;
|
|
83310
83322
|
}
|
|
83311
83323
|
}
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -6028,7 +6028,6 @@ var Diagnostics = {
|
|
|
6028
6028
|
Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
|
|
6029
6029
|
Import_attribute_values_must_be_string_literal_expressions: diag(2858, 1 /* Error */, "Import_attribute_values_must_be_string_literal_expressions_2858", "Import attribute values must be string literal expressions."),
|
|
6030
6030
|
Excessive_complexity_comparing_types_0_and_1: diag(2859, 1 /* Error */, "Excessive_complexity_comparing_types_0_and_1_2859", "Excessive complexity comparing types '{0}' and '{1}'."),
|
|
6031
|
-
The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1: diag(2860, 1 /* Error */, "The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1_2860", "The type of this declaration is ambiguous and may be observed as either '{0}' or '{1}'."),
|
|
6032
6031
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
6033
6032
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
6034
6033
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typescript-deploys/pr-build",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.3.0-pr-
|
|
5
|
+
"version": "5.3.0-pr-55887-24",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
"node": "20.1.0",
|
|
115
115
|
"npm": "8.19.4"
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "d03f3e11d626eae148c40a29328c7a1ad0350a2d"
|
|
118
118
|
}
|