typescript 4.9.0-dev.20221013 → 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 +109 -117
- package/lib/tsserver.js +281 -157
- package/lib/tsserverlibrary.js +281 -157
- package/lib/typescript.js +281 -157
- package/lib/typescriptServices.js +281 -157
- package/lib/typingsInstaller.js +130 -144
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -108,7 +108,7 @@ var ts;
|
|
|
108
108
|
// The following is baselined as a literal template type without intervention
|
|
109
109
|
/** The version of the TypeScript compiler release */
|
|
110
110
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
111
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
111
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221014");
|
|
112
112
|
/* @internal */
|
|
113
113
|
var Comparison;
|
|
114
114
|
(function (Comparison) {
|
|
@@ -9919,6 +9919,8 @@ var ts;
|
|
|
9919
9919
|
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}\""),
|
|
9920
9920
|
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9921
9921
|
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9922
|
+
Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
9923
|
+
Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
9922
9924
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9923
9925
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9924
9926
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -21679,6 +21681,32 @@ var ts;
|
|
|
21679
21681
|
return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21680
21682
|
}
|
|
21681
21683
|
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21684
|
+
function isTypeDeclaration(node) {
|
|
21685
|
+
switch (node.kind) {
|
|
21686
|
+
case 165 /* SyntaxKind.TypeParameter */:
|
|
21687
|
+
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
21688
|
+
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
21689
|
+
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
21690
|
+
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
21691
|
+
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
21692
|
+
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
21693
|
+
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
21694
|
+
return true;
|
|
21695
|
+
case 270 /* SyntaxKind.ImportClause */:
|
|
21696
|
+
return node.isTypeOnly;
|
|
21697
|
+
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
21698
|
+
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
21699
|
+
return node.parent.parent.isTypeOnly;
|
|
21700
|
+
default:
|
|
21701
|
+
return false;
|
|
21702
|
+
}
|
|
21703
|
+
}
|
|
21704
|
+
ts.isTypeDeclaration = isTypeDeclaration;
|
|
21705
|
+
function canHaveExportModifier(node) {
|
|
21706
|
+
return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
|
|
21707
|
+
|| ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
|
|
21708
|
+
}
|
|
21709
|
+
ts.canHaveExportModifier = canHaveExportModifier;
|
|
21682
21710
|
})(ts || (ts = {}));
|
|
21683
21711
|
/* @internal */
|
|
21684
21712
|
var ts;
|
|
@@ -49081,8 +49109,6 @@ var ts;
|
|
|
49081
49109
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
49082
49110
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
49083
49111
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
49084
|
-
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
49085
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
49086
49112
|
})(IntersectionState || (IntersectionState = {}));
|
|
49087
49113
|
var RecursionFlags;
|
|
49088
49114
|
(function (RecursionFlags) {
|
|
@@ -55424,7 +55450,7 @@ var ts;
|
|
|
55424
55450
|
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
|
|
55425
55451
|
var indices = ts.indicesOf(statements);
|
|
55426
55452
|
var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
|
|
55427
|
-
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
|
|
55453
|
+
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
|
|
55428
55454
|
for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
|
|
55429
55455
|
var index_1 = associatedIndices_1[_i];
|
|
55430
55456
|
statements[index_1] = addExportModifier(statements[index_1]);
|
|
@@ -55458,15 +55484,6 @@ var ts;
|
|
|
55458
55484
|
}
|
|
55459
55485
|
return statements;
|
|
55460
55486
|
}
|
|
55461
|
-
function canHaveExportModifier(node) {
|
|
55462
|
-
return ts.isEnumDeclaration(node) ||
|
|
55463
|
-
ts.isVariableStatement(node) ||
|
|
55464
|
-
ts.isFunctionDeclaration(node) ||
|
|
55465
|
-
ts.isClassDeclaration(node) ||
|
|
55466
|
-
(ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
|
|
55467
|
-
ts.isInterfaceDeclaration(node) ||
|
|
55468
|
-
isTypeDeclaration(node);
|
|
55469
|
-
}
|
|
55470
55487
|
function addExportModifier(node) {
|
|
55471
55488
|
var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
|
|
55472
55489
|
return ts.factory.updateModifiers(node, flags);
|
|
@@ -55713,7 +55730,7 @@ var ts;
|
|
|
55713
55730
|
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
55714
55731
|
if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
|
|
55715
55732
|
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
|
|
55716
|
-
canHaveExportModifier(node)) {
|
|
55733
|
+
ts.canHaveExportModifier(node)) {
|
|
55717
55734
|
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
|
|
55718
55735
|
newModifierFlags |= 1 /* ModifierFlags.Export */;
|
|
55719
55736
|
}
|
|
@@ -63840,18 +63857,23 @@ var ts;
|
|
|
63840
63857
|
var result;
|
|
63841
63858
|
var extraTypes;
|
|
63842
63859
|
var tailCount = 0;
|
|
63843
|
-
|
|
63860
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63861
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63862
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63863
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63864
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63865
|
+
while (true) {
|
|
63844
63866
|
if (tailCount === 1000) {
|
|
63845
63867
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63846
63868
|
result = errorType;
|
|
63847
|
-
|
|
63869
|
+
break;
|
|
63848
63870
|
}
|
|
63849
63871
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
63850
63872
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
63851
63873
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
63852
63874
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
63853
63875
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
63854
|
-
return
|
|
63876
|
+
return wildcardType;
|
|
63855
63877
|
}
|
|
63856
63878
|
var combinedMapper = void 0;
|
|
63857
63879
|
if (root.inferTypeParameters) {
|
|
@@ -63884,11 +63906,7 @@ var ts;
|
|
|
63884
63906
|
}
|
|
63885
63907
|
}
|
|
63886
63908
|
}
|
|
63887
|
-
|
|
63888
|
-
// if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
|
|
63889
|
-
// "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
|
|
63890
|
-
// so in those cases we refain from performing inference and retain the uninfered type parameter
|
|
63891
|
-
if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
|
|
63909
|
+
if (!checkTypeInstantiable) {
|
|
63892
63910
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
63893
63911
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
63894
63912
|
// types rules (i.e. proper contravariance) for inferences.
|
|
@@ -63920,14 +63938,14 @@ var ts;
|
|
|
63920
63938
|
var newRoot = falseType_1.root;
|
|
63921
63939
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
63922
63940
|
root = newRoot;
|
|
63923
|
-
|
|
63941
|
+
continue;
|
|
63924
63942
|
}
|
|
63925
63943
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
63926
|
-
|
|
63944
|
+
continue;
|
|
63927
63945
|
}
|
|
63928
63946
|
}
|
|
63929
63947
|
result = instantiateType(falseType_1, mapper);
|
|
63930
|
-
|
|
63948
|
+
break;
|
|
63931
63949
|
}
|
|
63932
63950
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
63933
63951
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -63938,10 +63956,10 @@ var ts;
|
|
|
63938
63956
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
63939
63957
|
var trueMapper = combinedMapper || mapper;
|
|
63940
63958
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
63941
|
-
|
|
63959
|
+
continue;
|
|
63942
63960
|
}
|
|
63943
63961
|
result = instantiateType(trueType_1, trueMapper);
|
|
63944
|
-
|
|
63962
|
+
break;
|
|
63945
63963
|
}
|
|
63946
63964
|
}
|
|
63947
63965
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -63953,19 +63971,7 @@ var ts;
|
|
|
63953
63971
|
result.combinedMapper = combinedMapper;
|
|
63954
63972
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
63955
63973
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
63956
|
-
|
|
63957
|
-
};
|
|
63958
|
-
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63959
|
-
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63960
|
-
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63961
|
-
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63962
|
-
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63963
|
-
while (true) {
|
|
63964
|
-
var state_6 = _loop_20();
|
|
63965
|
-
if (typeof state_6 === "object")
|
|
63966
|
-
return state_6.value;
|
|
63967
|
-
if (state_6 === "break")
|
|
63968
|
-
break;
|
|
63974
|
+
break;
|
|
63969
63975
|
}
|
|
63970
63976
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
63971
63977
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -66419,7 +66425,7 @@ var ts;
|
|
|
66419
66425
|
return 0 /* Ternary.False */;
|
|
66420
66426
|
}
|
|
66421
66427
|
}
|
|
66422
|
-
var isPerformingCommonPropertyChecks = (relation !== comparableRelation ||
|
|
66428
|
+
var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
|
|
66423
66429
|
!(intersectionState & 2 /* IntersectionState.Target */) &&
|
|
66424
66430
|
source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
|
|
66425
66431
|
target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
|
|
@@ -66447,27 +66453,6 @@ var ts;
|
|
|
66447
66453
|
var result_7 = skipCaching ?
|
|
66448
66454
|
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
66449
66455
|
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
66450
|
-
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66451
|
-
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66452
|
-
// examples that all should be errors, but aren't without this extra property check:
|
|
66453
|
-
//
|
|
66454
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66455
|
-
//
|
|
66456
|
-
// declare let wrong: { a: { y: string } };
|
|
66457
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66458
|
-
//
|
|
66459
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
66460
|
-
// x = y; // Mismatched property in source intersection
|
|
66461
|
-
// }
|
|
66462
|
-
//
|
|
66463
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
66464
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
66465
|
-
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
66466
|
-
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 */); }))) {
|
|
66467
|
-
inPropertyCheck = true;
|
|
66468
|
-
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
|
|
66469
|
-
inPropertyCheck = false;
|
|
66470
|
-
}
|
|
66471
66456
|
if (result_7) {
|
|
66472
66457
|
return result_7;
|
|
66473
66458
|
}
|
|
@@ -66579,7 +66564,7 @@ var ts;
|
|
|
66579
66564
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66580
66565
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66581
66566
|
}
|
|
66582
|
-
var
|
|
66567
|
+
var _loop_20 = function (prop) {
|
|
66583
66568
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66584
66569
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66585
66570
|
if (reportErrors) {
|
|
@@ -66642,9 +66627,9 @@ var ts;
|
|
|
66642
66627
|
};
|
|
66643
66628
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66644
66629
|
var prop = _b[_i];
|
|
66645
|
-
var
|
|
66646
|
-
if (typeof
|
|
66647
|
-
return
|
|
66630
|
+
var state_6 = _loop_20(prop);
|
|
66631
|
+
if (typeof state_6 === "object")
|
|
66632
|
+
return state_6.value;
|
|
66648
66633
|
}
|
|
66649
66634
|
return false;
|
|
66650
66635
|
}
|
|
@@ -66865,8 +66850,7 @@ var ts;
|
|
|
66865
66850
|
if (overflow) {
|
|
66866
66851
|
return 0 /* Ternary.False */;
|
|
66867
66852
|
}
|
|
66868
|
-
var
|
|
66869
|
-
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66853
|
+
var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66870
66854
|
var entry = relation.get(id);
|
|
66871
66855
|
if (entry !== undefined) {
|
|
66872
66856
|
if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
|
|
@@ -66896,7 +66880,7 @@ var ts;
|
|
|
66896
66880
|
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
66897
66881
|
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
66898
66882
|
// were unconstrained.
|
|
66899
|
-
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target,
|
|
66883
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
66900
66884
|
for (var i = 0; i < maybeCount; i++) {
|
|
66901
66885
|
// If source and target are already being compared, consider them related with assumptions
|
|
66902
66886
|
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
@@ -66983,7 +66967,7 @@ var ts;
|
|
|
66983
66967
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66984
66968
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66985
66969
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66986
|
-
if (
|
|
66970
|
+
if (relation !== identityRelation) {
|
|
66987
66971
|
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66988
66972
|
// the constituents. When an intersection type contains instantiable types with union type
|
|
66989
66973
|
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
@@ -66997,10 +66981,33 @@ var ts;
|
|
|
66997
66981
|
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66998
66982
|
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66999
66983
|
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
67000
|
-
|
|
67001
|
-
|
|
67002
|
-
|
|
67003
|
-
|
|
66984
|
+
if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
|
|
66985
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
|
|
66986
|
+
if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66987
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66988
|
+
result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66989
|
+
}
|
|
66990
|
+
}
|
|
66991
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66992
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66993
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
66994
|
+
//
|
|
66995
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66996
|
+
//
|
|
66997
|
+
// declare let wrong: { a: { y: string } };
|
|
66998
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66999
|
+
//
|
|
67000
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
67001
|
+
// x = y; // Mismatched property in source intersection
|
|
67002
|
+
// }
|
|
67003
|
+
//
|
|
67004
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
67005
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
67006
|
+
if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
|
|
67007
|
+
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 */); }))) {
|
|
67008
|
+
inPropertyCheck = true;
|
|
67009
|
+
result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67010
|
+
inPropertyCheck = false;
|
|
67004
67011
|
}
|
|
67005
67012
|
}
|
|
67006
67013
|
if (result) {
|
|
@@ -67009,9 +67016,6 @@ var ts;
|
|
|
67009
67016
|
return result;
|
|
67010
67017
|
}
|
|
67011
67018
|
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
67012
|
-
if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
|
|
67013
|
-
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67014
|
-
}
|
|
67015
67019
|
var result;
|
|
67016
67020
|
var originalErrorInfo;
|
|
67017
67021
|
var varianceCheckFailed = false;
|
|
@@ -67635,11 +67639,11 @@ var ts;
|
|
|
67635
67639
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67636
67640
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67637
67641
|
var matchingTypes = [];
|
|
67638
|
-
var
|
|
67642
|
+
var _loop_21 = function (combination) {
|
|
67639
67643
|
var hasMatch = false;
|
|
67640
67644
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67641
67645
|
var type = _d[_c];
|
|
67642
|
-
var
|
|
67646
|
+
var _loop_22 = function (i) {
|
|
67643
67647
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67644
67648
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67645
67649
|
if (!targetProperty)
|
|
@@ -67655,8 +67659,8 @@ var ts;
|
|
|
67655
67659
|
}
|
|
67656
67660
|
};
|
|
67657
67661
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67658
|
-
var
|
|
67659
|
-
switch (
|
|
67662
|
+
var state_8 = _loop_22(i);
|
|
67663
|
+
switch (state_8) {
|
|
67660
67664
|
case "continue-outer": continue outer;
|
|
67661
67665
|
}
|
|
67662
67666
|
}
|
|
@@ -67669,9 +67673,9 @@ var ts;
|
|
|
67669
67673
|
};
|
|
67670
67674
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67671
67675
|
var combination = discriminantCombinations_1[_a];
|
|
67672
|
-
var
|
|
67673
|
-
if (typeof
|
|
67674
|
-
return
|
|
67676
|
+
var state_7 = _loop_21(combination);
|
|
67677
|
+
if (typeof state_7 === "object")
|
|
67678
|
+
return state_7.value;
|
|
67675
67679
|
}
|
|
67676
67680
|
// Compare the remaining non-discriminant properties of each match.
|
|
67677
67681
|
var result = -1 /* Ternary.True */;
|
|
@@ -68376,7 +68380,7 @@ var ts;
|
|
|
68376
68380
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
68377
68381
|
links.variances = ts.emptyArray;
|
|
68378
68382
|
var variances = [];
|
|
68379
|
-
var
|
|
68383
|
+
var _loop_23 = function (tp) {
|
|
68380
68384
|
var modifiers = getVarianceModifiers(tp);
|
|
68381
68385
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68382
68386
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68414,7 +68418,7 @@ var ts;
|
|
|
68414
68418
|
};
|
|
68415
68419
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68416
68420
|
var tp = typeParameters_2[_i];
|
|
68417
|
-
|
|
68421
|
+
_loop_23(tp);
|
|
68418
68422
|
}
|
|
68419
68423
|
links.variances = variances;
|
|
68420
68424
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -70372,7 +70376,7 @@ var ts;
|
|
|
70372
70376
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70373
70377
|
// succeed. That would be a pointless and confusing outcome.
|
|
70374
70378
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70375
|
-
var
|
|
70379
|
+
var _loop_24 = function (i) {
|
|
70376
70380
|
var source_1 = matches ? matches[i] : neverType;
|
|
70377
70381
|
var target_3 = types[i];
|
|
70378
70382
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70422,7 +70426,7 @@ var ts;
|
|
|
70422
70426
|
inferFromTypes(source_1, target_3);
|
|
70423
70427
|
};
|
|
70424
70428
|
for (var i = 0; i < types.length; i++) {
|
|
70425
|
-
|
|
70429
|
+
_loop_24(i);
|
|
70426
70430
|
}
|
|
70427
70431
|
}
|
|
70428
70432
|
}
|
|
@@ -70951,7 +70955,7 @@ var ts;
|
|
|
70951
70955
|
function mapTypesByKeyProperty(types, name) {
|
|
70952
70956
|
var map = new ts.Map();
|
|
70953
70957
|
var count = 0;
|
|
70954
|
-
var
|
|
70958
|
+
var _loop_25 = function (type) {
|
|
70955
70959
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70956
70960
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70957
70961
|
if (discriminant) {
|
|
@@ -70977,9 +70981,9 @@ var ts;
|
|
|
70977
70981
|
};
|
|
70978
70982
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70979
70983
|
var type = types_15[_i];
|
|
70980
|
-
var
|
|
70981
|
-
if (typeof
|
|
70982
|
-
return
|
|
70984
|
+
var state_9 = _loop_25(type);
|
|
70985
|
+
if (typeof state_9 === "object")
|
|
70986
|
+
return state_9.value;
|
|
70983
70987
|
}
|
|
70984
70988
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70985
70989
|
}
|
|
@@ -77435,7 +77439,7 @@ var ts;
|
|
|
77435
77439
|
if (spreadIndex >= 0) {
|
|
77436
77440
|
// Create synthetic arguments from spreads of tuple types.
|
|
77437
77441
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77438
|
-
var
|
|
77442
|
+
var _loop_26 = function (i) {
|
|
77439
77443
|
var arg = args[i];
|
|
77440
77444
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77441
77445
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77452,7 +77456,7 @@ var ts;
|
|
|
77452
77456
|
}
|
|
77453
77457
|
};
|
|
77454
77458
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77455
|
-
|
|
77459
|
+
_loop_26(i);
|
|
77456
77460
|
}
|
|
77457
77461
|
return effectiveArgs_1;
|
|
77458
77462
|
}
|
|
@@ -77781,7 +77785,7 @@ var ts;
|
|
|
77781
77785
|
var min_3 = Number.MAX_VALUE;
|
|
77782
77786
|
var minIndex = 0;
|
|
77783
77787
|
var i_1 = 0;
|
|
77784
|
-
var
|
|
77788
|
+
var _loop_27 = function (c) {
|
|
77785
77789
|
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)); };
|
|
77786
77790
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77787
77791
|
if (diags_2) {
|
|
@@ -77799,7 +77803,7 @@ var ts;
|
|
|
77799
77803
|
};
|
|
77800
77804
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77801
77805
|
var c = candidatesForArgumentError_1[_a];
|
|
77802
|
-
|
|
77806
|
+
_loop_27(c);
|
|
77803
77807
|
}
|
|
77804
77808
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77805
77809
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77957,7 +77961,7 @@ var ts;
|
|
|
77957
77961
|
}
|
|
77958
77962
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77959
77963
|
var parameters = [];
|
|
77960
|
-
var
|
|
77964
|
+
var _loop_28 = function (i) {
|
|
77961
77965
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77962
77966
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77963
77967
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77965,7 +77969,7 @@ var ts;
|
|
|
77965
77969
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77966
77970
|
};
|
|
77967
77971
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77968
|
-
|
|
77972
|
+
_loop_28(i);
|
|
77969
77973
|
}
|
|
77970
77974
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77971
77975
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -82023,7 +82027,7 @@ var ts;
|
|
|
82023
82027
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
82024
82028
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
82025
82029
|
var indexSignatureMap_1 = new ts.Map();
|
|
82026
|
-
var
|
|
82030
|
+
var _loop_29 = function (declaration) {
|
|
82027
82031
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
82028
82032
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
82029
82033
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -82038,7 +82042,7 @@ var ts;
|
|
|
82038
82042
|
};
|
|
82039
82043
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
82040
82044
|
var declaration = _a[_i];
|
|
82041
|
-
|
|
82045
|
+
_loop_29(declaration);
|
|
82042
82046
|
}
|
|
82043
82047
|
indexSignatureMap_1.forEach(function (entry) {
|
|
82044
82048
|
if (entry.declarations.length > 1) {
|
|
@@ -82315,7 +82319,7 @@ var ts;
|
|
|
82315
82319
|
}
|
|
82316
82320
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
82317
82321
|
if (symbol) {
|
|
82318
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82322
|
+
if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82319
82323
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
82320
82324
|
}
|
|
82321
82325
|
if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
|
|
@@ -83693,7 +83697,7 @@ var ts;
|
|
|
83693
83697
|
}
|
|
83694
83698
|
function errorUnusedLocal(declaration, name, addDiagnostic) {
|
|
83695
83699
|
var node = ts.getNameOfDeclaration(declaration) || declaration;
|
|
83696
|
-
var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83700
|
+
var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83697
83701
|
addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
|
|
83698
83702
|
}
|
|
83699
83703
|
function isIdentifierThatStartsWithUnderscore(node) {
|
|
@@ -85647,7 +85651,7 @@ var ts;
|
|
|
85647
85651
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85648
85652
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85649
85653
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85650
|
-
var
|
|
85654
|
+
var _loop_30 = function (info) {
|
|
85651
85655
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85652
85656
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85653
85657
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85664,7 +85668,7 @@ var ts;
|
|
|
85664
85668
|
};
|
|
85665
85669
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85666
85670
|
var info = indexInfos_9[_i];
|
|
85667
|
-
|
|
85671
|
+
_loop_30(info);
|
|
85668
85672
|
}
|
|
85669
85673
|
}
|
|
85670
85674
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85672,7 +85676,7 @@ var ts;
|
|
|
85672
85676
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85673
85677
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85674
85678
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85675
|
-
var
|
|
85679
|
+
var _loop_31 = function (info) {
|
|
85676
85680
|
if (info === checkInfo)
|
|
85677
85681
|
return "continue";
|
|
85678
85682
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85687,7 +85691,7 @@ var ts;
|
|
|
85687
85691
|
};
|
|
85688
85692
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85689
85693
|
var info = indexInfos_10[_i];
|
|
85690
|
-
|
|
85694
|
+
_loop_31(info);
|
|
85691
85695
|
}
|
|
85692
85696
|
}
|
|
85693
85697
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85742,7 +85746,7 @@ var ts;
|
|
|
85742
85746
|
}
|
|
85743
85747
|
else {
|
|
85744
85748
|
ts.forEach(jsdocParameters, function (_a, index) {
|
|
85745
|
-
var name = _a.name;
|
|
85749
|
+
var name = _a.name, isNameFirst = _a.isNameFirst;
|
|
85746
85750
|
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
85747
85751
|
return;
|
|
85748
85752
|
}
|
|
@@ -85752,7 +85756,9 @@ var ts;
|
|
|
85752
85756
|
}
|
|
85753
85757
|
}
|
|
85754
85758
|
else {
|
|
85755
|
-
|
|
85759
|
+
if (!isNameFirst) {
|
|
85760
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
85761
|
+
}
|
|
85756
85762
|
}
|
|
85757
85763
|
});
|
|
85758
85764
|
}
|
|
@@ -86007,7 +86013,7 @@ var ts;
|
|
|
86007
86013
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
86008
86014
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
86009
86015
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
86010
|
-
var
|
|
86016
|
+
var _loop_32 = function (member) {
|
|
86011
86017
|
if (ts.hasAmbientModifier(member)) {
|
|
86012
86018
|
return "continue";
|
|
86013
86019
|
}
|
|
@@ -86024,7 +86030,7 @@ var ts;
|
|
|
86024
86030
|
};
|
|
86025
86031
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86026
86032
|
var member = _a[_i];
|
|
86027
|
-
|
|
86033
|
+
_loop_32(member);
|
|
86028
86034
|
}
|
|
86029
86035
|
}
|
|
86030
86036
|
/**
|
|
@@ -86112,7 +86118,7 @@ var ts;
|
|
|
86112
86118
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
86113
86119
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
86114
86120
|
var issuedMemberError = false;
|
|
86115
|
-
var
|
|
86121
|
+
var _loop_33 = function (member) {
|
|
86116
86122
|
if (ts.isStatic(member)) {
|
|
86117
86123
|
return "continue";
|
|
86118
86124
|
}
|
|
@@ -86131,7 +86137,7 @@ var ts;
|
|
|
86131
86137
|
};
|
|
86132
86138
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86133
86139
|
var member = _a[_i];
|
|
86134
|
-
|
|
86140
|
+
_loop_33(member);
|
|
86135
86141
|
}
|
|
86136
86142
|
if (!issuedMemberError) {
|
|
86137
86143
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -86202,7 +86208,7 @@ var ts;
|
|
|
86202
86208
|
var _a, _b, _c, _d;
|
|
86203
86209
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
86204
86210
|
var baseProperties = getPropertiesOfType(baseType);
|
|
86205
|
-
var
|
|
86211
|
+
var _loop_34 = function (baseProperty) {
|
|
86206
86212
|
var base = getTargetSymbol(baseProperty);
|
|
86207
86213
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
86208
86214
|
return "continue";
|
|
@@ -86312,8 +86318,8 @@ var ts;
|
|
|
86312
86318
|
};
|
|
86313
86319
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86314
86320
|
var baseProperty = baseProperties_1[_i];
|
|
86315
|
-
var
|
|
86316
|
-
switch (
|
|
86321
|
+
var state_10 = _loop_34(baseProperty);
|
|
86322
|
+
switch (state_10) {
|
|
86317
86323
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86318
86324
|
}
|
|
86319
86325
|
}
|
|
@@ -88023,29 +88029,9 @@ var ts;
|
|
|
88023
88029
|
}
|
|
88024
88030
|
function isTypeDeclarationName(name) {
|
|
88025
88031
|
return name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
88026
|
-
isTypeDeclaration(name.parent) &&
|
|
88032
|
+
ts.isTypeDeclaration(name.parent) &&
|
|
88027
88033
|
ts.getNameOfDeclaration(name.parent) === name;
|
|
88028
88034
|
}
|
|
88029
|
-
function isTypeDeclaration(node) {
|
|
88030
|
-
switch (node.kind) {
|
|
88031
|
-
case 165 /* SyntaxKind.TypeParameter */:
|
|
88032
|
-
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
88033
|
-
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
88034
|
-
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
88035
|
-
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
88036
|
-
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
88037
|
-
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
88038
|
-
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
88039
|
-
return true;
|
|
88040
|
-
case 270 /* SyntaxKind.ImportClause */:
|
|
88041
|
-
return node.isTypeOnly;
|
|
88042
|
-
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88043
|
-
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88044
|
-
return node.parent.parent.isTypeOnly;
|
|
88045
|
-
default:
|
|
88046
|
-
return false;
|
|
88047
|
-
}
|
|
88048
|
-
}
|
|
88049
88035
|
// True if the given identifier is part of a type reference
|
|
88050
88036
|
function isTypeReferenceIdentifier(node) {
|
|
88051
88037
|
while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
|
|
@@ -88478,7 +88464,7 @@ var ts;
|
|
|
88478
88464
|
var baseType = ts.firstOrUndefined(getBaseTypes(classType));
|
|
88479
88465
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
|
88480
88466
|
}
|
|
88481
|
-
if (isTypeDeclaration(node)) {
|
|
88467
|
+
if (ts.isTypeDeclaration(node)) {
|
|
88482
88468
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
88483
88469
|
var symbol = getSymbolOfNode(node);
|
|
88484
88470
|
return getDeclaredTypeOfSymbol(symbol);
|
|
@@ -125164,7 +125150,7 @@ var ts;
|
|
|
125164
125150
|
});
|
|
125165
125151
|
// Sort by paths closest to importing file Name directory
|
|
125166
125152
|
var sortedPaths = [];
|
|
125167
|
-
var
|
|
125153
|
+
var _loop_35 = function (directory) {
|
|
125168
125154
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
125169
125155
|
var pathsInDirectory;
|
|
125170
125156
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -125188,9 +125174,9 @@ var ts;
|
|
|
125188
125174
|
};
|
|
125189
125175
|
var out_directory_1;
|
|
125190
125176
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
125191
|
-
var
|
|
125177
|
+
var state_11 = _loop_35(directory);
|
|
125192
125178
|
directory = out_directory_1;
|
|
125193
|
-
if (
|
|
125179
|
+
if (state_11 === "break")
|
|
125194
125180
|
break;
|
|
125195
125181
|
}
|
|
125196
125182
|
if (allFileNames.size) {
|
|
@@ -125259,7 +125245,7 @@ var ts;
|
|
|
125259
125245
|
}
|
|
125260
125246
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125261
125247
|
for (var key in paths) {
|
|
125262
|
-
var
|
|
125248
|
+
var _loop_36 = function (patternText_1) {
|
|
125263
125249
|
var pattern = ts.normalizePath(patternText_1);
|
|
125264
125250
|
var indexOfStar = pattern.indexOf("*");
|
|
125265
125251
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125326,9 +125312,9 @@ var ts;
|
|
|
125326
125312
|
};
|
|
125327
125313
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125328
125314
|
var patternText_1 = _a[_i];
|
|
125329
|
-
var
|
|
125330
|
-
if (typeof
|
|
125331
|
-
return
|
|
125315
|
+
var state_12 = _loop_36(patternText_1);
|
|
125316
|
+
if (typeof state_12 === "object")
|
|
125317
|
+
return state_12.value;
|
|
125332
125318
|
}
|
|
125333
125319
|
}
|
|
125334
125320
|
function validateEnding(_a) {
|
|
@@ -132858,6 +132844,10 @@ var ts;
|
|
|
132858
132844
|
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
|
|
132859
132845
|
}
|
|
132860
132846
|
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
132847
|
+
function isSourceFileFromLibrary(program, node) {
|
|
132848
|
+
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
132849
|
+
}
|
|
132850
|
+
ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
|
|
132861
132851
|
// #endregion
|
|
132862
132852
|
})(ts || (ts = {}));
|
|
132863
132853
|
/*@internal*/
|
|
@@ -157965,6 +157955,143 @@ var ts;
|
|
|
157965
157955
|
})(ts || (ts = {}));
|
|
157966
157956
|
/* @internal */
|
|
157967
157957
|
var ts;
|
|
157958
|
+
(function (ts) {
|
|
157959
|
+
var codefix;
|
|
157960
|
+
(function (codefix) {
|
|
157961
|
+
var fixId = "fixImportNonExportedMember";
|
|
157962
|
+
var errorCodes = [
|
|
157963
|
+
ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
|
|
157964
|
+
];
|
|
157965
|
+
codefix.registerCodeFix({
|
|
157966
|
+
errorCodes: errorCodes,
|
|
157967
|
+
fixIds: [fixId],
|
|
157968
|
+
getCodeActions: function (context) {
|
|
157969
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
157970
|
+
var info = getInfo(sourceFile, span.start, program);
|
|
157971
|
+
if (info === undefined)
|
|
157972
|
+
return undefined;
|
|
157973
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
|
|
157974
|
+
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)];
|
|
157975
|
+
},
|
|
157976
|
+
getAllCodeActions: function (context) {
|
|
157977
|
+
var program = context.program;
|
|
157978
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
157979
|
+
var exports = new ts.Map();
|
|
157980
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
157981
|
+
var info = getInfo(diag.file, diag.start, program);
|
|
157982
|
+
if (info === undefined)
|
|
157983
|
+
return undefined;
|
|
157984
|
+
var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
|
|
157985
|
+
if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
|
|
157986
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157987
|
+
}
|
|
157988
|
+
else {
|
|
157989
|
+
var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
|
|
157990
|
+
if (exportName.isTypeOnly) {
|
|
157991
|
+
moduleExports.typeOnlyExports.push(exportName);
|
|
157992
|
+
}
|
|
157993
|
+
else {
|
|
157994
|
+
moduleExports.exports.push(exportName);
|
|
157995
|
+
}
|
|
157996
|
+
exports.set(moduleSourceFile, moduleExports);
|
|
157997
|
+
}
|
|
157998
|
+
});
|
|
157999
|
+
exports.forEach(function (moduleExports, moduleSourceFile) {
|
|
158000
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
|
|
158001
|
+
if (exportDeclaration && exportDeclaration.isTypeOnly) {
|
|
158002
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
|
|
158003
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
|
|
158004
|
+
}
|
|
158005
|
+
else {
|
|
158006
|
+
doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
|
|
158007
|
+
}
|
|
158008
|
+
});
|
|
158009
|
+
}));
|
|
158010
|
+
}
|
|
158011
|
+
});
|
|
158012
|
+
function getInfo(sourceFile, pos, program) {
|
|
158013
|
+
var _a;
|
|
158014
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
158015
|
+
if (ts.isIdentifier(token)) {
|
|
158016
|
+
var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
|
|
158017
|
+
if (importDeclaration === undefined)
|
|
158018
|
+
return undefined;
|
|
158019
|
+
var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
|
158020
|
+
if (moduleSpecifier === undefined)
|
|
158021
|
+
return undefined;
|
|
158022
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
|
|
158023
|
+
if (resolvedModule === undefined)
|
|
158024
|
+
return undefined;
|
|
158025
|
+
var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
158026
|
+
if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
|
|
158027
|
+
return undefined;
|
|
158028
|
+
var moduleSymbol = moduleSourceFile.symbol;
|
|
158029
|
+
var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
|
|
158030
|
+
if (locals === undefined)
|
|
158031
|
+
return undefined;
|
|
158032
|
+
var localSymbol = locals.get(token.escapedText);
|
|
158033
|
+
if (localSymbol === undefined)
|
|
158034
|
+
return undefined;
|
|
158035
|
+
var node = getNodeOfSymbol(localSymbol);
|
|
158036
|
+
if (node === undefined)
|
|
158037
|
+
return undefined;
|
|
158038
|
+
var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
|
|
158039
|
+
return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
|
|
158040
|
+
}
|
|
158041
|
+
return undefined;
|
|
158042
|
+
}
|
|
158043
|
+
function doChange(changes, program, _a) {
|
|
158044
|
+
var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
|
|
158045
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
158046
|
+
if (exportDeclaration) {
|
|
158047
|
+
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
158048
|
+
}
|
|
158049
|
+
else if (ts.canHaveExportModifier(node)) {
|
|
158050
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
158051
|
+
}
|
|
158052
|
+
else {
|
|
158053
|
+
createExport(changes, program, moduleSourceFile, [exportName]);
|
|
158054
|
+
}
|
|
158055
|
+
}
|
|
158056
|
+
function doChanges(changes, program, sourceFile, moduleExports, node) {
|
|
158057
|
+
if (ts.length(moduleExports)) {
|
|
158058
|
+
if (node) {
|
|
158059
|
+
updateExport(changes, program, sourceFile, node, moduleExports);
|
|
158060
|
+
}
|
|
158061
|
+
else {
|
|
158062
|
+
createExport(changes, program, sourceFile, moduleExports);
|
|
158063
|
+
}
|
|
158064
|
+
}
|
|
158065
|
+
}
|
|
158066
|
+
function tryGetExportDeclaration(sourceFile, isTypeOnly) {
|
|
158067
|
+
var predicate = function (node) {
|
|
158068
|
+
return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
|
|
158069
|
+
};
|
|
158070
|
+
return ts.findLast(sourceFile.statements, predicate);
|
|
158071
|
+
}
|
|
158072
|
+
function updateExport(changes, program, sourceFile, node, names) {
|
|
158073
|
+
var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
|
|
158074
|
+
var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
|
|
158075
|
+
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));
|
|
158076
|
+
}
|
|
158077
|
+
function createExport(changes, program, sourceFile, names) {
|
|
158078
|
+
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
|
|
158079
|
+
}
|
|
158080
|
+
function createExportSpecifiers(names, allowTypeModifier) {
|
|
158081
|
+
return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
|
|
158082
|
+
}
|
|
158083
|
+
function getNodeOfSymbol(symbol) {
|
|
158084
|
+
if (symbol.valueDeclaration === undefined) {
|
|
158085
|
+
return ts.firstOrUndefined(symbol.declarations);
|
|
158086
|
+
}
|
|
158087
|
+
var declaration = symbol.valueDeclaration;
|
|
158088
|
+
var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
|
|
158089
|
+
return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
158090
|
+
}
|
|
158091
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
158092
|
+
})(ts || (ts = {}));
|
|
158093
|
+
/* @internal */
|
|
158094
|
+
var ts;
|
|
157968
158095
|
(function (ts) {
|
|
157969
158096
|
var codefix;
|
|
157970
158097
|
(function (codefix) {
|
|
@@ -158495,7 +158622,7 @@ var ts;
|
|
|
158495
158622
|
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
|
|
158496
158623
|
if (argIndex < 0)
|
|
158497
158624
|
return undefined;
|
|
158498
|
-
var signature =
|
|
158625
|
+
var signature = checker.getResolvedSignature(parent.parent);
|
|
158499
158626
|
if (!(signature && signature.declaration && signature.parameters[argIndex]))
|
|
158500
158627
|
return undefined;
|
|
158501
158628
|
var param = signature.parameters[argIndex].valueDeclaration;
|
|
@@ -158542,13 +158669,13 @@ var ts;
|
|
|
158542
158669
|
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
|
|
158543
158670
|
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
|
|
158544
158671
|
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
|
|
158545
|
-
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158672
|
+
if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158546
158673
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
|
|
158547
158674
|
}
|
|
158548
158675
|
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
|
|
158549
158676
|
if (sourceFile.commonJsModuleIndicator)
|
|
158550
158677
|
return undefined;
|
|
158551
|
-
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158678
|
+
if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158552
158679
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
|
|
158553
158680
|
}
|
|
158554
158681
|
}
|
|
@@ -158558,7 +158685,7 @@ var ts;
|
|
|
158558
158685
|
return undefined;
|
|
158559
158686
|
// Prefer to change the class instead of the interface if they are merged
|
|
158560
158687
|
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
158561
|
-
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158688
|
+
if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158562
158689
|
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
158563
158690
|
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
158564
158691
|
return undefined;
|
|
@@ -158570,14 +158697,11 @@ var ts;
|
|
|
158570
158697
|
return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
158571
158698
|
}
|
|
158572
158699
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
158573
|
-
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158700
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158574
158701
|
return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
|
|
158575
158702
|
}
|
|
158576
158703
|
return undefined;
|
|
158577
158704
|
}
|
|
158578
|
-
function isSourceFileFromLibrary(program, node) {
|
|
158579
|
-
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
158580
|
-
}
|
|
158581
158705
|
function getActionsForMissingMemberDeclaration(context, info) {
|
|
158582
158706
|
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
|
|
158583
158707
|
createActionsForAddMissingMemberInTypeScriptFile(context, info);
|
|
@@ -164003,8 +164127,8 @@ var ts;
|
|
|
164003
164127
|
var i = 0;
|
|
164004
164128
|
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
|
|
164005
164129
|
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
|
|
164006
|
-
var description = functionExtraction.description;
|
|
164007
164130
|
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
164131
|
+
var description = functionExtraction.description;
|
|
164008
164132
|
if (functionExtraction.errors.length === 0) {
|
|
164009
164133
|
// Don't issue refactorings with duplicated names.
|
|
164010
164134
|
// Scopes come back in "innermost first" order, so extractions will
|
|
@@ -164028,15 +164152,15 @@ var ts;
|
|
|
164028
164152
|
}
|
|
164029
164153
|
}
|
|
164030
164154
|
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
164155
|
+
var description = constantExtraction.description;
|
|
164031
164156
|
if (constantExtraction.errors.length === 0) {
|
|
164032
164157
|
// Don't issue refactorings with duplicated names.
|
|
164033
164158
|
// Scopes come back in "innermost first" order, so extractions will
|
|
164034
164159
|
// preferentially go into nearer scopes
|
|
164035
|
-
|
|
164036
|
-
|
|
164037
|
-
usedConstantNames.set(description_1, true);
|
|
164160
|
+
if (!usedConstantNames.has(description)) {
|
|
164161
|
+
usedConstantNames.set(description, true);
|
|
164038
164162
|
constantActions.push({
|
|
164039
|
-
description:
|
|
164163
|
+
description: description,
|
|
164040
164164
|
name: "constant_scope_".concat(i),
|
|
164041
164165
|
kind: extractConstantAction.kind
|
|
164042
164166
|
});
|