typescript 4.9.0-dev.20221012 → 4.9.0-dev.20221014
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 +122 -120
- package/lib/tsserver.js +294 -160
- package/lib/tsserverlibrary.js +294 -160
- package/lib/typescript.js +294 -160
- package/lib/typescriptServices.js +294 -160
- package/lib/typingsInstaller.js +143 -147
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -99,7 +99,7 @@ var ts;
|
|
|
99
99
|
// The following is baselined as a literal template type without intervention
|
|
100
100
|
/** The version of the TypeScript compiler release */
|
|
101
101
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
102
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
102
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221014");
|
|
103
103
|
/* @internal */
|
|
104
104
|
var Comparison;
|
|
105
105
|
(function (Comparison) {
|
|
@@ -9910,6 +9910,8 @@ var ts;
|
|
|
9910
9910
|
Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
|
|
9911
9911
|
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9912
9912
|
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9913
|
+
Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
9914
|
+
Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
9913
9915
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9914
9916
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9915
9917
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -21670,6 +21672,32 @@ var ts;
|
|
|
21670
21672
|
return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21671
21673
|
}
|
|
21672
21674
|
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21675
|
+
function isTypeDeclaration(node) {
|
|
21676
|
+
switch (node.kind) {
|
|
21677
|
+
case 165 /* SyntaxKind.TypeParameter */:
|
|
21678
|
+
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
21679
|
+
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
21680
|
+
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
21681
|
+
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
21682
|
+
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
21683
|
+
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
21684
|
+
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
21685
|
+
return true;
|
|
21686
|
+
case 270 /* SyntaxKind.ImportClause */:
|
|
21687
|
+
return node.isTypeOnly;
|
|
21688
|
+
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
21689
|
+
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
21690
|
+
return node.parent.parent.isTypeOnly;
|
|
21691
|
+
default:
|
|
21692
|
+
return false;
|
|
21693
|
+
}
|
|
21694
|
+
}
|
|
21695
|
+
ts.isTypeDeclaration = isTypeDeclaration;
|
|
21696
|
+
function canHaveExportModifier(node) {
|
|
21697
|
+
return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
|
|
21698
|
+
|| ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
|
|
21699
|
+
}
|
|
21700
|
+
ts.canHaveExportModifier = canHaveExportModifier;
|
|
21673
21701
|
})(ts || (ts = {}));
|
|
21674
21702
|
/* @internal */
|
|
21675
21703
|
var ts;
|
|
@@ -49072,8 +49100,6 @@ var ts;
|
|
|
49072
49100
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
49073
49101
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
49074
49102
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
49075
|
-
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
49076
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
49077
49103
|
})(IntersectionState || (IntersectionState = {}));
|
|
49078
49104
|
var RecursionFlags;
|
|
49079
49105
|
(function (RecursionFlags) {
|
|
@@ -55415,7 +55441,7 @@ var ts;
|
|
|
55415
55441
|
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
|
|
55416
55442
|
var indices = ts.indicesOf(statements);
|
|
55417
55443
|
var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
|
|
55418
|
-
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
|
|
55444
|
+
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
|
|
55419
55445
|
for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
|
|
55420
55446
|
var index_1 = associatedIndices_1[_i];
|
|
55421
55447
|
statements[index_1] = addExportModifier(statements[index_1]);
|
|
@@ -55449,15 +55475,6 @@ var ts;
|
|
|
55449
55475
|
}
|
|
55450
55476
|
return statements;
|
|
55451
55477
|
}
|
|
55452
|
-
function canHaveExportModifier(node) {
|
|
55453
|
-
return ts.isEnumDeclaration(node) ||
|
|
55454
|
-
ts.isVariableStatement(node) ||
|
|
55455
|
-
ts.isFunctionDeclaration(node) ||
|
|
55456
|
-
ts.isClassDeclaration(node) ||
|
|
55457
|
-
(ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
|
|
55458
|
-
ts.isInterfaceDeclaration(node) ||
|
|
55459
|
-
isTypeDeclaration(node);
|
|
55460
|
-
}
|
|
55461
55478
|
function addExportModifier(node) {
|
|
55462
55479
|
var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
|
|
55463
55480
|
return ts.factory.updateModifiers(node, flags);
|
|
@@ -55704,7 +55721,7 @@ var ts;
|
|
|
55704
55721
|
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
55705
55722
|
if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
|
|
55706
55723
|
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
|
|
55707
|
-
canHaveExportModifier(node)) {
|
|
55724
|
+
ts.canHaveExportModifier(node)) {
|
|
55708
55725
|
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
|
|
55709
55726
|
newModifierFlags |= 1 /* ModifierFlags.Export */;
|
|
55710
55727
|
}
|
|
@@ -63831,18 +63848,23 @@ var ts;
|
|
|
63831
63848
|
var result;
|
|
63832
63849
|
var extraTypes;
|
|
63833
63850
|
var tailCount = 0;
|
|
63834
|
-
|
|
63851
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63852
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63853
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63854
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63855
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63856
|
+
while (true) {
|
|
63835
63857
|
if (tailCount === 1000) {
|
|
63836
63858
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63837
63859
|
result = errorType;
|
|
63838
|
-
|
|
63860
|
+
break;
|
|
63839
63861
|
}
|
|
63840
63862
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
63841
63863
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
63842
63864
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
63843
63865
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
63844
63866
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
63845
|
-
return
|
|
63867
|
+
return wildcardType;
|
|
63846
63868
|
}
|
|
63847
63869
|
var combinedMapper = void 0;
|
|
63848
63870
|
if (root.inferTypeParameters) {
|
|
@@ -63875,11 +63897,7 @@ var ts;
|
|
|
63875
63897
|
}
|
|
63876
63898
|
}
|
|
63877
63899
|
}
|
|
63878
|
-
|
|
63879
|
-
// if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
|
|
63880
|
-
// "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
|
|
63881
|
-
// so in those cases we refain from performing inference and retain the uninfered type parameter
|
|
63882
|
-
if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
|
|
63900
|
+
if (!checkTypeInstantiable) {
|
|
63883
63901
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
63884
63902
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
63885
63903
|
// types rules (i.e. proper contravariance) for inferences.
|
|
@@ -63911,14 +63929,14 @@ var ts;
|
|
|
63911
63929
|
var newRoot = falseType_1.root;
|
|
63912
63930
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
63913
63931
|
root = newRoot;
|
|
63914
|
-
|
|
63932
|
+
continue;
|
|
63915
63933
|
}
|
|
63916
63934
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
63917
|
-
|
|
63935
|
+
continue;
|
|
63918
63936
|
}
|
|
63919
63937
|
}
|
|
63920
63938
|
result = instantiateType(falseType_1, mapper);
|
|
63921
|
-
|
|
63939
|
+
break;
|
|
63922
63940
|
}
|
|
63923
63941
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
63924
63942
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -63929,10 +63947,10 @@ var ts;
|
|
|
63929
63947
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
63930
63948
|
var trueMapper = combinedMapper || mapper;
|
|
63931
63949
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
63932
|
-
|
|
63950
|
+
continue;
|
|
63933
63951
|
}
|
|
63934
63952
|
result = instantiateType(trueType_1, trueMapper);
|
|
63935
|
-
|
|
63953
|
+
break;
|
|
63936
63954
|
}
|
|
63937
63955
|
}
|
|
63938
63956
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -63944,19 +63962,7 @@ var ts;
|
|
|
63944
63962
|
result.combinedMapper = combinedMapper;
|
|
63945
63963
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
63946
63964
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
63947
|
-
|
|
63948
|
-
};
|
|
63949
|
-
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63950
|
-
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63951
|
-
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63952
|
-
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63953
|
-
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63954
|
-
while (true) {
|
|
63955
|
-
var state_6 = _loop_20();
|
|
63956
|
-
if (typeof state_6 === "object")
|
|
63957
|
-
return state_6.value;
|
|
63958
|
-
if (state_6 === "break")
|
|
63959
|
-
break;
|
|
63965
|
+
break;
|
|
63960
63966
|
}
|
|
63961
63967
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
63962
63968
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -66410,7 +66416,7 @@ var ts;
|
|
|
66410
66416
|
return 0 /* Ternary.False */;
|
|
66411
66417
|
}
|
|
66412
66418
|
}
|
|
66413
|
-
var isPerformingCommonPropertyChecks = (relation !== comparableRelation ||
|
|
66419
|
+
var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
|
|
66414
66420
|
!(intersectionState & 2 /* IntersectionState.Target */) &&
|
|
66415
66421
|
source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
|
|
66416
66422
|
target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
|
|
@@ -66438,27 +66444,6 @@ var ts;
|
|
|
66438
66444
|
var result_7 = skipCaching ?
|
|
66439
66445
|
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
66440
66446
|
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
66441
|
-
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66442
|
-
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66443
|
-
// examples that all should be errors, but aren't without this extra property check:
|
|
66444
|
-
//
|
|
66445
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66446
|
-
//
|
|
66447
|
-
// declare let wrong: { a: { y: string } };
|
|
66448
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66449
|
-
//
|
|
66450
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
66451
|
-
// x = y; // Mismatched property in source intersection
|
|
66452
|
-
// }
|
|
66453
|
-
//
|
|
66454
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
66455
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
66456
|
-
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
66457
|
-
isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
|
|
66458
|
-
inPropertyCheck = true;
|
|
66459
|
-
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
|
|
66460
|
-
inPropertyCheck = false;
|
|
66461
|
-
}
|
|
66462
66447
|
if (result_7) {
|
|
66463
66448
|
return result_7;
|
|
66464
66449
|
}
|
|
@@ -66570,7 +66555,7 @@ var ts;
|
|
|
66570
66555
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66571
66556
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66572
66557
|
}
|
|
66573
|
-
var
|
|
66558
|
+
var _loop_20 = function (prop) {
|
|
66574
66559
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66575
66560
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66576
66561
|
if (reportErrors) {
|
|
@@ -66633,9 +66618,9 @@ var ts;
|
|
|
66633
66618
|
};
|
|
66634
66619
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66635
66620
|
var prop = _b[_i];
|
|
66636
|
-
var
|
|
66637
|
-
if (typeof
|
|
66638
|
-
return
|
|
66621
|
+
var state_6 = _loop_20(prop);
|
|
66622
|
+
if (typeof state_6 === "object")
|
|
66623
|
+
return state_6.value;
|
|
66639
66624
|
}
|
|
66640
66625
|
return false;
|
|
66641
66626
|
}
|
|
@@ -66856,8 +66841,7 @@ var ts;
|
|
|
66856
66841
|
if (overflow) {
|
|
66857
66842
|
return 0 /* Ternary.False */;
|
|
66858
66843
|
}
|
|
66859
|
-
var
|
|
66860
|
-
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66844
|
+
var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66861
66845
|
var entry = relation.get(id);
|
|
66862
66846
|
if (entry !== undefined) {
|
|
66863
66847
|
if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
|
|
@@ -66887,7 +66871,7 @@ var ts;
|
|
|
66887
66871
|
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
66888
66872
|
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
66889
66873
|
// were unconstrained.
|
|
66890
|
-
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target,
|
|
66874
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
66891
66875
|
for (var i = 0; i < maybeCount; i++) {
|
|
66892
66876
|
// If source and target are already being compared, consider them related with assumptions
|
|
66893
66877
|
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
@@ -66974,7 +66958,7 @@ var ts;
|
|
|
66974
66958
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66975
66959
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66976
66960
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66977
|
-
if (
|
|
66961
|
+
if (relation !== identityRelation) {
|
|
66978
66962
|
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66979
66963
|
// the constituents. When an intersection type contains instantiable types with union type
|
|
66980
66964
|
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
@@ -66988,10 +66972,33 @@ var ts;
|
|
|
66988
66972
|
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66989
66973
|
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66990
66974
|
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66991
|
-
|
|
66992
|
-
|
|
66993
|
-
|
|
66994
|
-
|
|
66975
|
+
if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
|
|
66976
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
|
|
66977
|
+
if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66978
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66979
|
+
result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66980
|
+
}
|
|
66981
|
+
}
|
|
66982
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66983
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66984
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
66985
|
+
//
|
|
66986
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66987
|
+
//
|
|
66988
|
+
// declare let wrong: { a: { y: string } };
|
|
66989
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66990
|
+
//
|
|
66991
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
66992
|
+
// x = y; // Mismatched property in source intersection
|
|
66993
|
+
// }
|
|
66994
|
+
//
|
|
66995
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
66996
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
66997
|
+
if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
|
|
66998
|
+
isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
|
|
66999
|
+
inPropertyCheck = true;
|
|
67000
|
+
result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67001
|
+
inPropertyCheck = false;
|
|
66995
67002
|
}
|
|
66996
67003
|
}
|
|
66997
67004
|
if (result) {
|
|
@@ -67000,9 +67007,6 @@ var ts;
|
|
|
67000
67007
|
return result;
|
|
67001
67008
|
}
|
|
67002
67009
|
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
67003
|
-
if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
|
|
67004
|
-
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67005
|
-
}
|
|
67006
67010
|
var result;
|
|
67007
67011
|
var originalErrorInfo;
|
|
67008
67012
|
var varianceCheckFailed = false;
|
|
@@ -67626,11 +67630,11 @@ var ts;
|
|
|
67626
67630
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67627
67631
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67628
67632
|
var matchingTypes = [];
|
|
67629
|
-
var
|
|
67633
|
+
var _loop_21 = function (combination) {
|
|
67630
67634
|
var hasMatch = false;
|
|
67631
67635
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67632
67636
|
var type = _d[_c];
|
|
67633
|
-
var
|
|
67637
|
+
var _loop_22 = function (i) {
|
|
67634
67638
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67635
67639
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67636
67640
|
if (!targetProperty)
|
|
@@ -67646,8 +67650,8 @@ var ts;
|
|
|
67646
67650
|
}
|
|
67647
67651
|
};
|
|
67648
67652
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67649
|
-
var
|
|
67650
|
-
switch (
|
|
67653
|
+
var state_8 = _loop_22(i);
|
|
67654
|
+
switch (state_8) {
|
|
67651
67655
|
case "continue-outer": continue outer;
|
|
67652
67656
|
}
|
|
67653
67657
|
}
|
|
@@ -67660,9 +67664,9 @@ var ts;
|
|
|
67660
67664
|
};
|
|
67661
67665
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67662
67666
|
var combination = discriminantCombinations_1[_a];
|
|
67663
|
-
var
|
|
67664
|
-
if (typeof
|
|
67665
|
-
return
|
|
67667
|
+
var state_7 = _loop_21(combination);
|
|
67668
|
+
if (typeof state_7 === "object")
|
|
67669
|
+
return state_7.value;
|
|
67666
67670
|
}
|
|
67667
67671
|
// Compare the remaining non-discriminant properties of each match.
|
|
67668
67672
|
var result = -1 /* Ternary.True */;
|
|
@@ -68367,7 +68371,7 @@ var ts;
|
|
|
68367
68371
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
68368
68372
|
links.variances = ts.emptyArray;
|
|
68369
68373
|
var variances = [];
|
|
68370
|
-
var
|
|
68374
|
+
var _loop_23 = function (tp) {
|
|
68371
68375
|
var modifiers = getVarianceModifiers(tp);
|
|
68372
68376
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68373
68377
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68405,7 +68409,7 @@ var ts;
|
|
|
68405
68409
|
};
|
|
68406
68410
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68407
68411
|
var tp = typeParameters_2[_i];
|
|
68408
|
-
|
|
68412
|
+
_loop_23(tp);
|
|
68409
68413
|
}
|
|
68410
68414
|
links.variances = variances;
|
|
68411
68415
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -70363,7 +70367,7 @@ var ts;
|
|
|
70363
70367
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70364
70368
|
// succeed. That would be a pointless and confusing outcome.
|
|
70365
70369
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70366
|
-
var
|
|
70370
|
+
var _loop_24 = function (i) {
|
|
70367
70371
|
var source_1 = matches ? matches[i] : neverType;
|
|
70368
70372
|
var target_3 = types[i];
|
|
70369
70373
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70413,7 +70417,7 @@ var ts;
|
|
|
70413
70417
|
inferFromTypes(source_1, target_3);
|
|
70414
70418
|
};
|
|
70415
70419
|
for (var i = 0; i < types.length; i++) {
|
|
70416
|
-
|
|
70420
|
+
_loop_24(i);
|
|
70417
70421
|
}
|
|
70418
70422
|
}
|
|
70419
70423
|
}
|
|
@@ -70942,7 +70946,7 @@ var ts;
|
|
|
70942
70946
|
function mapTypesByKeyProperty(types, name) {
|
|
70943
70947
|
var map = new ts.Map();
|
|
70944
70948
|
var count = 0;
|
|
70945
|
-
var
|
|
70949
|
+
var _loop_25 = function (type) {
|
|
70946
70950
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70947
70951
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70948
70952
|
if (discriminant) {
|
|
@@ -70968,9 +70972,9 @@ var ts;
|
|
|
70968
70972
|
};
|
|
70969
70973
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70970
70974
|
var type = types_15[_i];
|
|
70971
|
-
var
|
|
70972
|
-
if (typeof
|
|
70973
|
-
return
|
|
70975
|
+
var state_9 = _loop_25(type);
|
|
70976
|
+
if (typeof state_9 === "object")
|
|
70977
|
+
return state_9.value;
|
|
70974
70978
|
}
|
|
70975
70979
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70976
70980
|
}
|
|
@@ -77426,7 +77430,7 @@ var ts;
|
|
|
77426
77430
|
if (spreadIndex >= 0) {
|
|
77427
77431
|
// Create synthetic arguments from spreads of tuple types.
|
|
77428
77432
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77429
|
-
var
|
|
77433
|
+
var _loop_26 = function (i) {
|
|
77430
77434
|
var arg = args[i];
|
|
77431
77435
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77432
77436
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77443,7 +77447,7 @@ var ts;
|
|
|
77443
77447
|
}
|
|
77444
77448
|
};
|
|
77445
77449
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77446
|
-
|
|
77450
|
+
_loop_26(i);
|
|
77447
77451
|
}
|
|
77448
77452
|
return effectiveArgs_1;
|
|
77449
77453
|
}
|
|
@@ -77772,7 +77776,7 @@ var ts;
|
|
|
77772
77776
|
var min_3 = Number.MAX_VALUE;
|
|
77773
77777
|
var minIndex = 0;
|
|
77774
77778
|
var i_1 = 0;
|
|
77775
|
-
var
|
|
77779
|
+
var _loop_27 = function (c) {
|
|
77776
77780
|
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
|
77777
77781
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77778
77782
|
if (diags_2) {
|
|
@@ -77790,7 +77794,7 @@ var ts;
|
|
|
77790
77794
|
};
|
|
77791
77795
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77792
77796
|
var c = candidatesForArgumentError_1[_a];
|
|
77793
|
-
|
|
77797
|
+
_loop_27(c);
|
|
77794
77798
|
}
|
|
77795
77799
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77796
77800
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77948,7 +77952,7 @@ var ts;
|
|
|
77948
77952
|
}
|
|
77949
77953
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77950
77954
|
var parameters = [];
|
|
77951
|
-
var
|
|
77955
|
+
var _loop_28 = function (i) {
|
|
77952
77956
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77953
77957
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77954
77958
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77956,7 +77960,7 @@ var ts;
|
|
|
77956
77960
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77957
77961
|
};
|
|
77958
77962
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77959
|
-
|
|
77963
|
+
_loop_28(i);
|
|
77960
77964
|
}
|
|
77961
77965
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77962
77966
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -79588,7 +79592,17 @@ var ts;
|
|
|
79588
79592
|
}
|
|
79589
79593
|
function isExhaustiveSwitchStatement(node) {
|
|
79590
79594
|
var links = getNodeLinks(node);
|
|
79591
|
-
|
|
79595
|
+
if (links.isExhaustive === undefined) {
|
|
79596
|
+
links.isExhaustive = 0; // Indicate resolution is in process
|
|
79597
|
+
var exhaustive = computeExhaustiveSwitchStatement(node);
|
|
79598
|
+
if (links.isExhaustive === 0) {
|
|
79599
|
+
links.isExhaustive = exhaustive;
|
|
79600
|
+
}
|
|
79601
|
+
}
|
|
79602
|
+
else if (links.isExhaustive === 0) {
|
|
79603
|
+
links.isExhaustive = false; // Resolve circularity to false
|
|
79604
|
+
}
|
|
79605
|
+
return links.isExhaustive;
|
|
79592
79606
|
}
|
|
79593
79607
|
function computeExhaustiveSwitchStatement(node) {
|
|
79594
79608
|
if (node.expression.kind === 218 /* SyntaxKind.TypeOfExpression */) {
|
|
@@ -79596,7 +79610,7 @@ var ts;
|
|
|
79596
79610
|
if (!witnesses) {
|
|
79597
79611
|
return false;
|
|
79598
79612
|
}
|
|
79599
|
-
var operandConstraint = getBaseConstraintOrType(
|
|
79613
|
+
var operandConstraint = getBaseConstraintOrType(checkExpressionCached(node.expression.expression));
|
|
79600
79614
|
// Get the not-equal flags for all handled cases.
|
|
79601
79615
|
var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
|
|
79602
79616
|
if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) {
|
|
@@ -79606,7 +79620,7 @@ var ts;
|
|
|
79606
79620
|
// A missing not-equal flag indicates that the type wasn't handled by some case.
|
|
79607
79621
|
return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
|
|
79608
79622
|
}
|
|
79609
|
-
var type =
|
|
79623
|
+
var type = checkExpressionCached(node.expression);
|
|
79610
79624
|
if (!isLiteralType(type)) {
|
|
79611
79625
|
return false;
|
|
79612
79626
|
}
|
|
@@ -82004,7 +82018,7 @@ var ts;
|
|
|
82004
82018
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
82005
82019
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
82006
82020
|
var indexSignatureMap_1 = new ts.Map();
|
|
82007
|
-
var
|
|
82021
|
+
var _loop_29 = function (declaration) {
|
|
82008
82022
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
82009
82023
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
82010
82024
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -82019,7 +82033,7 @@ var ts;
|
|
|
82019
82033
|
};
|
|
82020
82034
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
82021
82035
|
var declaration = _a[_i];
|
|
82022
|
-
|
|
82036
|
+
_loop_29(declaration);
|
|
82023
82037
|
}
|
|
82024
82038
|
indexSignatureMap_1.forEach(function (entry) {
|
|
82025
82039
|
if (entry.declarations.length > 1) {
|
|
@@ -82296,7 +82310,7 @@ var ts;
|
|
|
82296
82310
|
}
|
|
82297
82311
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
82298
82312
|
if (symbol) {
|
|
82299
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82313
|
+
if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82300
82314
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
82301
82315
|
}
|
|
82302
82316
|
if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
|
|
@@ -83674,7 +83688,7 @@ var ts;
|
|
|
83674
83688
|
}
|
|
83675
83689
|
function errorUnusedLocal(declaration, name, addDiagnostic) {
|
|
83676
83690
|
var node = ts.getNameOfDeclaration(declaration) || declaration;
|
|
83677
|
-
var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83691
|
+
var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83678
83692
|
addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
|
|
83679
83693
|
}
|
|
83680
83694
|
function isIdentifierThatStartsWithUnderscore(node) {
|
|
@@ -85628,7 +85642,7 @@ var ts;
|
|
|
85628
85642
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85629
85643
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85630
85644
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85631
|
-
var
|
|
85645
|
+
var _loop_30 = function (info) {
|
|
85632
85646
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85633
85647
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85634
85648
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85645,7 +85659,7 @@ var ts;
|
|
|
85645
85659
|
};
|
|
85646
85660
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85647
85661
|
var info = indexInfos_9[_i];
|
|
85648
|
-
|
|
85662
|
+
_loop_30(info);
|
|
85649
85663
|
}
|
|
85650
85664
|
}
|
|
85651
85665
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85653,7 +85667,7 @@ var ts;
|
|
|
85653
85667
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85654
85668
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85655
85669
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85656
|
-
var
|
|
85670
|
+
var _loop_31 = function (info) {
|
|
85657
85671
|
if (info === checkInfo)
|
|
85658
85672
|
return "continue";
|
|
85659
85673
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85668,7 +85682,7 @@ var ts;
|
|
|
85668
85682
|
};
|
|
85669
85683
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85670
85684
|
var info = indexInfos_10[_i];
|
|
85671
|
-
|
|
85685
|
+
_loop_31(info);
|
|
85672
85686
|
}
|
|
85673
85687
|
}
|
|
85674
85688
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85723,7 +85737,7 @@ var ts;
|
|
|
85723
85737
|
}
|
|
85724
85738
|
else {
|
|
85725
85739
|
ts.forEach(jsdocParameters, function (_a, index) {
|
|
85726
|
-
var name = _a.name;
|
|
85740
|
+
var name = _a.name, isNameFirst = _a.isNameFirst;
|
|
85727
85741
|
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
85728
85742
|
return;
|
|
85729
85743
|
}
|
|
@@ -85733,7 +85747,9 @@ var ts;
|
|
|
85733
85747
|
}
|
|
85734
85748
|
}
|
|
85735
85749
|
else {
|
|
85736
|
-
|
|
85750
|
+
if (!isNameFirst) {
|
|
85751
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
85752
|
+
}
|
|
85737
85753
|
}
|
|
85738
85754
|
});
|
|
85739
85755
|
}
|
|
@@ -85988,7 +86004,7 @@ var ts;
|
|
|
85988
86004
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
85989
86005
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
85990
86006
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
85991
|
-
var
|
|
86007
|
+
var _loop_32 = function (member) {
|
|
85992
86008
|
if (ts.hasAmbientModifier(member)) {
|
|
85993
86009
|
return "continue";
|
|
85994
86010
|
}
|
|
@@ -86005,7 +86021,7 @@ var ts;
|
|
|
86005
86021
|
};
|
|
86006
86022
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86007
86023
|
var member = _a[_i];
|
|
86008
|
-
|
|
86024
|
+
_loop_32(member);
|
|
86009
86025
|
}
|
|
86010
86026
|
}
|
|
86011
86027
|
/**
|
|
@@ -86093,7 +86109,7 @@ var ts;
|
|
|
86093
86109
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
86094
86110
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
86095
86111
|
var issuedMemberError = false;
|
|
86096
|
-
var
|
|
86112
|
+
var _loop_33 = function (member) {
|
|
86097
86113
|
if (ts.isStatic(member)) {
|
|
86098
86114
|
return "continue";
|
|
86099
86115
|
}
|
|
@@ -86112,7 +86128,7 @@ var ts;
|
|
|
86112
86128
|
};
|
|
86113
86129
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86114
86130
|
var member = _a[_i];
|
|
86115
|
-
|
|
86131
|
+
_loop_33(member);
|
|
86116
86132
|
}
|
|
86117
86133
|
if (!issuedMemberError) {
|
|
86118
86134
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -86183,7 +86199,7 @@ var ts;
|
|
|
86183
86199
|
var _a, _b, _c, _d;
|
|
86184
86200
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
86185
86201
|
var baseProperties = getPropertiesOfType(baseType);
|
|
86186
|
-
var
|
|
86202
|
+
var _loop_34 = function (baseProperty) {
|
|
86187
86203
|
var base = getTargetSymbol(baseProperty);
|
|
86188
86204
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
86189
86205
|
return "continue";
|
|
@@ -86293,8 +86309,8 @@ var ts;
|
|
|
86293
86309
|
};
|
|
86294
86310
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86295
86311
|
var baseProperty = baseProperties_1[_i];
|
|
86296
|
-
var
|
|
86297
|
-
switch (
|
|
86312
|
+
var state_10 = _loop_34(baseProperty);
|
|
86313
|
+
switch (state_10) {
|
|
86298
86314
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86299
86315
|
}
|
|
86300
86316
|
}
|
|
@@ -88004,29 +88020,9 @@ var ts;
|
|
|
88004
88020
|
}
|
|
88005
88021
|
function isTypeDeclarationName(name) {
|
|
88006
88022
|
return name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
88007
|
-
isTypeDeclaration(name.parent) &&
|
|
88023
|
+
ts.isTypeDeclaration(name.parent) &&
|
|
88008
88024
|
ts.getNameOfDeclaration(name.parent) === name;
|
|
88009
88025
|
}
|
|
88010
|
-
function isTypeDeclaration(node) {
|
|
88011
|
-
switch (node.kind) {
|
|
88012
|
-
case 165 /* SyntaxKind.TypeParameter */:
|
|
88013
|
-
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
88014
|
-
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
88015
|
-
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
88016
|
-
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
88017
|
-
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
88018
|
-
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
88019
|
-
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
88020
|
-
return true;
|
|
88021
|
-
case 270 /* SyntaxKind.ImportClause */:
|
|
88022
|
-
return node.isTypeOnly;
|
|
88023
|
-
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88024
|
-
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88025
|
-
return node.parent.parent.isTypeOnly;
|
|
88026
|
-
default:
|
|
88027
|
-
return false;
|
|
88028
|
-
}
|
|
88029
|
-
}
|
|
88030
88026
|
// True if the given identifier is part of a type reference
|
|
88031
88027
|
function isTypeReferenceIdentifier(node) {
|
|
88032
88028
|
while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
|
|
@@ -88459,7 +88455,7 @@ var ts;
|
|
|
88459
88455
|
var baseType = ts.firstOrUndefined(getBaseTypes(classType));
|
|
88460
88456
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
|
88461
88457
|
}
|
|
88462
|
-
if (isTypeDeclaration(node)) {
|
|
88458
|
+
if (ts.isTypeDeclaration(node)) {
|
|
88463
88459
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
88464
88460
|
var symbol = getSymbolOfNode(node);
|
|
88465
88461
|
return getDeclaredTypeOfSymbol(symbol);
|
|
@@ -125145,7 +125141,7 @@ var ts;
|
|
|
125145
125141
|
});
|
|
125146
125142
|
// Sort by paths closest to importing file Name directory
|
|
125147
125143
|
var sortedPaths = [];
|
|
125148
|
-
var
|
|
125144
|
+
var _loop_35 = function (directory) {
|
|
125149
125145
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
125150
125146
|
var pathsInDirectory;
|
|
125151
125147
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -125169,9 +125165,9 @@ var ts;
|
|
|
125169
125165
|
};
|
|
125170
125166
|
var out_directory_1;
|
|
125171
125167
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
125172
|
-
var
|
|
125168
|
+
var state_11 = _loop_35(directory);
|
|
125173
125169
|
directory = out_directory_1;
|
|
125174
|
-
if (
|
|
125170
|
+
if (state_11 === "break")
|
|
125175
125171
|
break;
|
|
125176
125172
|
}
|
|
125177
125173
|
if (allFileNames.size) {
|
|
@@ -125240,7 +125236,7 @@ var ts;
|
|
|
125240
125236
|
}
|
|
125241
125237
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125242
125238
|
for (var key in paths) {
|
|
125243
|
-
var
|
|
125239
|
+
var _loop_36 = function (patternText_1) {
|
|
125244
125240
|
var pattern = ts.normalizePath(patternText_1);
|
|
125245
125241
|
var indexOfStar = pattern.indexOf("*");
|
|
125246
125242
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125307,9 +125303,9 @@ var ts;
|
|
|
125307
125303
|
};
|
|
125308
125304
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125309
125305
|
var patternText_1 = _a[_i];
|
|
125310
|
-
var
|
|
125311
|
-
if (typeof
|
|
125312
|
-
return
|
|
125306
|
+
var state_12 = _loop_36(patternText_1);
|
|
125307
|
+
if (typeof state_12 === "object")
|
|
125308
|
+
return state_12.value;
|
|
125313
125309
|
}
|
|
125314
125310
|
}
|
|
125315
125311
|
function validateEnding(_a) {
|
|
@@ -132839,6 +132835,10 @@ var ts;
|
|
|
132839
132835
|
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
|
|
132840
132836
|
}
|
|
132841
132837
|
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
132838
|
+
function isSourceFileFromLibrary(program, node) {
|
|
132839
|
+
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
132840
|
+
}
|
|
132841
|
+
ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
|
|
132842
132842
|
// #endregion
|
|
132843
132843
|
})(ts || (ts = {}));
|
|
132844
132844
|
/*@internal*/
|
|
@@ -157946,6 +157946,143 @@ var ts;
|
|
|
157946
157946
|
})(ts || (ts = {}));
|
|
157947
157947
|
/* @internal */
|
|
157948
157948
|
var ts;
|
|
157949
|
+
(function (ts) {
|
|
157950
|
+
var codefix;
|
|
157951
|
+
(function (codefix) {
|
|
157952
|
+
var fixId = "fixImportNonExportedMember";
|
|
157953
|
+
var errorCodes = [
|
|
157954
|
+
ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
|
|
157955
|
+
];
|
|
157956
|
+
codefix.registerCodeFix({
|
|
157957
|
+
errorCodes: errorCodes,
|
|
157958
|
+
fixIds: [fixId],
|
|
157959
|
+
getCodeActions: function (context) {
|
|
157960
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
157961
|
+
var info = getInfo(sourceFile, span.start, program);
|
|
157962
|
+
if (info === undefined)
|
|
157963
|
+
return undefined;
|
|
157964
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
|
|
157965
|
+
return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId, ts.Diagnostics.Export_all_referenced_locals)];
|
|
157966
|
+
},
|
|
157967
|
+
getAllCodeActions: function (context) {
|
|
157968
|
+
var program = context.program;
|
|
157969
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
157970
|
+
var exports = new ts.Map();
|
|
157971
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
157972
|
+
var info = getInfo(diag.file, diag.start, program);
|
|
157973
|
+
if (info === undefined)
|
|
157974
|
+
return undefined;
|
|
157975
|
+
var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
|
|
157976
|
+
if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
|
|
157977
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157978
|
+
}
|
|
157979
|
+
else {
|
|
157980
|
+
var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
|
|
157981
|
+
if (exportName.isTypeOnly) {
|
|
157982
|
+
moduleExports.typeOnlyExports.push(exportName);
|
|
157983
|
+
}
|
|
157984
|
+
else {
|
|
157985
|
+
moduleExports.exports.push(exportName);
|
|
157986
|
+
}
|
|
157987
|
+
exports.set(moduleSourceFile, moduleExports);
|
|
157988
|
+
}
|
|
157989
|
+
});
|
|
157990
|
+
exports.forEach(function (moduleExports, moduleSourceFile) {
|
|
157991
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
|
|
157992
|
+
if (exportDeclaration && exportDeclaration.isTypeOnly) {
|
|
157993
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
|
|
157994
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
|
|
157995
|
+
}
|
|
157996
|
+
else {
|
|
157997
|
+
doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
|
|
157998
|
+
}
|
|
157999
|
+
});
|
|
158000
|
+
}));
|
|
158001
|
+
}
|
|
158002
|
+
});
|
|
158003
|
+
function getInfo(sourceFile, pos, program) {
|
|
158004
|
+
var _a;
|
|
158005
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
158006
|
+
if (ts.isIdentifier(token)) {
|
|
158007
|
+
var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
|
|
158008
|
+
if (importDeclaration === undefined)
|
|
158009
|
+
return undefined;
|
|
158010
|
+
var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
|
158011
|
+
if (moduleSpecifier === undefined)
|
|
158012
|
+
return undefined;
|
|
158013
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
|
|
158014
|
+
if (resolvedModule === undefined)
|
|
158015
|
+
return undefined;
|
|
158016
|
+
var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
158017
|
+
if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
|
|
158018
|
+
return undefined;
|
|
158019
|
+
var moduleSymbol = moduleSourceFile.symbol;
|
|
158020
|
+
var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
|
|
158021
|
+
if (locals === undefined)
|
|
158022
|
+
return undefined;
|
|
158023
|
+
var localSymbol = locals.get(token.escapedText);
|
|
158024
|
+
if (localSymbol === undefined)
|
|
158025
|
+
return undefined;
|
|
158026
|
+
var node = getNodeOfSymbol(localSymbol);
|
|
158027
|
+
if (node === undefined)
|
|
158028
|
+
return undefined;
|
|
158029
|
+
var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
|
|
158030
|
+
return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
|
|
158031
|
+
}
|
|
158032
|
+
return undefined;
|
|
158033
|
+
}
|
|
158034
|
+
function doChange(changes, program, _a) {
|
|
158035
|
+
var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
|
|
158036
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
158037
|
+
if (exportDeclaration) {
|
|
158038
|
+
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
158039
|
+
}
|
|
158040
|
+
else if (ts.canHaveExportModifier(node)) {
|
|
158041
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
158042
|
+
}
|
|
158043
|
+
else {
|
|
158044
|
+
createExport(changes, program, moduleSourceFile, [exportName]);
|
|
158045
|
+
}
|
|
158046
|
+
}
|
|
158047
|
+
function doChanges(changes, program, sourceFile, moduleExports, node) {
|
|
158048
|
+
if (ts.length(moduleExports)) {
|
|
158049
|
+
if (node) {
|
|
158050
|
+
updateExport(changes, program, sourceFile, node, moduleExports);
|
|
158051
|
+
}
|
|
158052
|
+
else {
|
|
158053
|
+
createExport(changes, program, sourceFile, moduleExports);
|
|
158054
|
+
}
|
|
158055
|
+
}
|
|
158056
|
+
}
|
|
158057
|
+
function tryGetExportDeclaration(sourceFile, isTypeOnly) {
|
|
158058
|
+
var predicate = function (node) {
|
|
158059
|
+
return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
|
|
158060
|
+
};
|
|
158061
|
+
return ts.findLast(sourceFile.statements, predicate);
|
|
158062
|
+
}
|
|
158063
|
+
function updateExport(changes, program, sourceFile, node, names) {
|
|
158064
|
+
var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
|
|
158065
|
+
var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
|
|
158066
|
+
changes.replaceNode(sourceFile, node, ts.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, ts.factory.createNamedExports(ts.factory.createNodeArray(__spreadArray(__spreadArray([], namedExports, true), createExportSpecifiers(names, allowTypeModifier), true), /*hasTrailingComma*/ namedExports.hasTrailingComma)), node.moduleSpecifier, node.assertClause));
|
|
158067
|
+
}
|
|
158068
|
+
function createExport(changes, program, sourceFile, names) {
|
|
158069
|
+
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
|
|
158070
|
+
}
|
|
158071
|
+
function createExportSpecifiers(names, allowTypeModifier) {
|
|
158072
|
+
return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
|
|
158073
|
+
}
|
|
158074
|
+
function getNodeOfSymbol(symbol) {
|
|
158075
|
+
if (symbol.valueDeclaration === undefined) {
|
|
158076
|
+
return ts.firstOrUndefined(symbol.declarations);
|
|
158077
|
+
}
|
|
158078
|
+
var declaration = symbol.valueDeclaration;
|
|
158079
|
+
var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
|
|
158080
|
+
return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
158081
|
+
}
|
|
158082
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
158083
|
+
})(ts || (ts = {}));
|
|
158084
|
+
/* @internal */
|
|
158085
|
+
var ts;
|
|
157949
158086
|
(function (ts) {
|
|
157950
158087
|
var codefix;
|
|
157951
158088
|
(function (codefix) {
|
|
@@ -158476,7 +158613,7 @@ var ts;
|
|
|
158476
158613
|
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
|
|
158477
158614
|
if (argIndex < 0)
|
|
158478
158615
|
return undefined;
|
|
158479
|
-
var signature =
|
|
158616
|
+
var signature = checker.getResolvedSignature(parent.parent);
|
|
158480
158617
|
if (!(signature && signature.declaration && signature.parameters[argIndex]))
|
|
158481
158618
|
return undefined;
|
|
158482
158619
|
var param = signature.parameters[argIndex].valueDeclaration;
|
|
@@ -158523,13 +158660,13 @@ var ts;
|
|
|
158523
158660
|
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
|
|
158524
158661
|
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
|
|
158525
158662
|
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
|
|
158526
|
-
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158663
|
+
if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158527
158664
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
|
|
158528
158665
|
}
|
|
158529
158666
|
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
|
|
158530
158667
|
if (sourceFile.commonJsModuleIndicator)
|
|
158531
158668
|
return undefined;
|
|
158532
|
-
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158669
|
+
if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158533
158670
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
|
|
158534
158671
|
}
|
|
158535
158672
|
}
|
|
@@ -158539,7 +158676,7 @@ var ts;
|
|
|
158539
158676
|
return undefined;
|
|
158540
158677
|
// Prefer to change the class instead of the interface if they are merged
|
|
158541
158678
|
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
158542
|
-
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158679
|
+
if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158543
158680
|
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
158544
158681
|
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
158545
158682
|
return undefined;
|
|
@@ -158551,14 +158688,11 @@ var ts;
|
|
|
158551
158688
|
return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
158552
158689
|
}
|
|
158553
158690
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
158554
|
-
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158691
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158555
158692
|
return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
|
|
158556
158693
|
}
|
|
158557
158694
|
return undefined;
|
|
158558
158695
|
}
|
|
158559
|
-
function isSourceFileFromLibrary(program, node) {
|
|
158560
|
-
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
158561
|
-
}
|
|
158562
158696
|
function getActionsForMissingMemberDeclaration(context, info) {
|
|
158563
158697
|
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
|
|
158564
158698
|
createActionsForAddMissingMemberInTypeScriptFile(context, info);
|
|
@@ -163984,8 +164118,8 @@ var ts;
|
|
|
163984
164118
|
var i = 0;
|
|
163985
164119
|
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
|
|
163986
164120
|
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
|
|
163987
|
-
var description = functionExtraction.description;
|
|
163988
164121
|
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
164122
|
+
var description = functionExtraction.description;
|
|
163989
164123
|
if (functionExtraction.errors.length === 0) {
|
|
163990
164124
|
// Don't issue refactorings with duplicated names.
|
|
163991
164125
|
// Scopes come back in "innermost first" order, so extractions will
|
|
@@ -164009,15 +164143,15 @@ var ts;
|
|
|
164009
164143
|
}
|
|
164010
164144
|
}
|
|
164011
164145
|
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
164146
|
+
var description = constantExtraction.description;
|
|
164012
164147
|
if (constantExtraction.errors.length === 0) {
|
|
164013
164148
|
// Don't issue refactorings with duplicated names.
|
|
164014
164149
|
// Scopes come back in "innermost first" order, so extractions will
|
|
164015
164150
|
// preferentially go into nearer scopes
|
|
164016
|
-
|
|
164017
|
-
|
|
164018
|
-
usedConstantNames.set(description_1, true);
|
|
164151
|
+
if (!usedConstantNames.has(description)) {
|
|
164152
|
+
usedConstantNames.set(description, true);
|
|
164019
164153
|
constantActions.push({
|
|
164020
|
-
description:
|
|
164154
|
+
description: description,
|
|
164021
164155
|
name: "constant_scope_".concat(i),
|
|
164022
164156
|
kind: extractConstantAction.kind
|
|
164023
164157
|
});
|