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/tsserver.js
CHANGED
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
112
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221014");
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -9920,6 +9920,8 @@ var ts;
|
|
|
9920
9920
|
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}\""),
|
|
9921
9921
|
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9922
9922
|
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9923
|
+
Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
9924
|
+
Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
9923
9925
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9924
9926
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9925
9927
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -21680,6 +21682,32 @@ var ts;
|
|
|
21680
21682
|
return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21681
21683
|
}
|
|
21682
21684
|
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21685
|
+
function isTypeDeclaration(node) {
|
|
21686
|
+
switch (node.kind) {
|
|
21687
|
+
case 165 /* SyntaxKind.TypeParameter */:
|
|
21688
|
+
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
21689
|
+
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
21690
|
+
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
21691
|
+
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
21692
|
+
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
21693
|
+
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
21694
|
+
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
21695
|
+
return true;
|
|
21696
|
+
case 270 /* SyntaxKind.ImportClause */:
|
|
21697
|
+
return node.isTypeOnly;
|
|
21698
|
+
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
21699
|
+
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
21700
|
+
return node.parent.parent.isTypeOnly;
|
|
21701
|
+
default:
|
|
21702
|
+
return false;
|
|
21703
|
+
}
|
|
21704
|
+
}
|
|
21705
|
+
ts.isTypeDeclaration = isTypeDeclaration;
|
|
21706
|
+
function canHaveExportModifier(node) {
|
|
21707
|
+
return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
|
|
21708
|
+
|| ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
|
|
21709
|
+
}
|
|
21710
|
+
ts.canHaveExportModifier = canHaveExportModifier;
|
|
21683
21711
|
})(ts || (ts = {}));
|
|
21684
21712
|
/* @internal */
|
|
21685
21713
|
var ts;
|
|
@@ -49082,8 +49110,6 @@ var ts;
|
|
|
49082
49110
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
49083
49111
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
49084
49112
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
49085
|
-
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
49086
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
49087
49113
|
})(IntersectionState || (IntersectionState = {}));
|
|
49088
49114
|
var RecursionFlags;
|
|
49089
49115
|
(function (RecursionFlags) {
|
|
@@ -55425,7 +55451,7 @@ var ts;
|
|
|
55425
55451
|
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
|
|
55426
55452
|
var indices = ts.indicesOf(statements);
|
|
55427
55453
|
var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
|
|
55428
|
-
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
|
|
55454
|
+
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
|
|
55429
55455
|
for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
|
|
55430
55456
|
var index_1 = associatedIndices_1[_i];
|
|
55431
55457
|
statements[index_1] = addExportModifier(statements[index_1]);
|
|
@@ -55459,15 +55485,6 @@ var ts;
|
|
|
55459
55485
|
}
|
|
55460
55486
|
return statements;
|
|
55461
55487
|
}
|
|
55462
|
-
function canHaveExportModifier(node) {
|
|
55463
|
-
return ts.isEnumDeclaration(node) ||
|
|
55464
|
-
ts.isVariableStatement(node) ||
|
|
55465
|
-
ts.isFunctionDeclaration(node) ||
|
|
55466
|
-
ts.isClassDeclaration(node) ||
|
|
55467
|
-
(ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
|
|
55468
|
-
ts.isInterfaceDeclaration(node) ||
|
|
55469
|
-
isTypeDeclaration(node);
|
|
55470
|
-
}
|
|
55471
55488
|
function addExportModifier(node) {
|
|
55472
55489
|
var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
|
|
55473
55490
|
return ts.factory.updateModifiers(node, flags);
|
|
@@ -55714,7 +55731,7 @@ var ts;
|
|
|
55714
55731
|
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
55715
55732
|
if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
|
|
55716
55733
|
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
|
|
55717
|
-
canHaveExportModifier(node)) {
|
|
55734
|
+
ts.canHaveExportModifier(node)) {
|
|
55718
55735
|
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
|
|
55719
55736
|
newModifierFlags |= 1 /* ModifierFlags.Export */;
|
|
55720
55737
|
}
|
|
@@ -63841,18 +63858,23 @@ var ts;
|
|
|
63841
63858
|
var result;
|
|
63842
63859
|
var extraTypes;
|
|
63843
63860
|
var tailCount = 0;
|
|
63844
|
-
|
|
63861
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63862
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63863
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63864
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63865
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63866
|
+
while (true) {
|
|
63845
63867
|
if (tailCount === 1000) {
|
|
63846
63868
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63847
63869
|
result = errorType;
|
|
63848
|
-
|
|
63870
|
+
break;
|
|
63849
63871
|
}
|
|
63850
63872
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
63851
63873
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
63852
63874
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
63853
63875
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
63854
63876
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
63855
|
-
return
|
|
63877
|
+
return wildcardType;
|
|
63856
63878
|
}
|
|
63857
63879
|
var combinedMapper = void 0;
|
|
63858
63880
|
if (root.inferTypeParameters) {
|
|
@@ -63885,11 +63907,7 @@ var ts;
|
|
|
63885
63907
|
}
|
|
63886
63908
|
}
|
|
63887
63909
|
}
|
|
63888
|
-
|
|
63889
|
-
// if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
|
|
63890
|
-
// "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
|
|
63891
|
-
// so in those cases we refain from performing inference and retain the uninfered type parameter
|
|
63892
|
-
if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
|
|
63910
|
+
if (!checkTypeInstantiable) {
|
|
63893
63911
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
63894
63912
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
63895
63913
|
// types rules (i.e. proper contravariance) for inferences.
|
|
@@ -63921,14 +63939,14 @@ var ts;
|
|
|
63921
63939
|
var newRoot = falseType_1.root;
|
|
63922
63940
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
63923
63941
|
root = newRoot;
|
|
63924
|
-
|
|
63942
|
+
continue;
|
|
63925
63943
|
}
|
|
63926
63944
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
63927
|
-
|
|
63945
|
+
continue;
|
|
63928
63946
|
}
|
|
63929
63947
|
}
|
|
63930
63948
|
result = instantiateType(falseType_1, mapper);
|
|
63931
|
-
|
|
63949
|
+
break;
|
|
63932
63950
|
}
|
|
63933
63951
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
63934
63952
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -63939,10 +63957,10 @@ var ts;
|
|
|
63939
63957
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
63940
63958
|
var trueMapper = combinedMapper || mapper;
|
|
63941
63959
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
63942
|
-
|
|
63960
|
+
continue;
|
|
63943
63961
|
}
|
|
63944
63962
|
result = instantiateType(trueType_1, trueMapper);
|
|
63945
|
-
|
|
63963
|
+
break;
|
|
63946
63964
|
}
|
|
63947
63965
|
}
|
|
63948
63966
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -63954,19 +63972,7 @@ var ts;
|
|
|
63954
63972
|
result.combinedMapper = combinedMapper;
|
|
63955
63973
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
63956
63974
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
63957
|
-
|
|
63958
|
-
};
|
|
63959
|
-
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63960
|
-
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63961
|
-
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63962
|
-
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63963
|
-
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63964
|
-
while (true) {
|
|
63965
|
-
var state_6 = _loop_20();
|
|
63966
|
-
if (typeof state_6 === "object")
|
|
63967
|
-
return state_6.value;
|
|
63968
|
-
if (state_6 === "break")
|
|
63969
|
-
break;
|
|
63975
|
+
break;
|
|
63970
63976
|
}
|
|
63971
63977
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
63972
63978
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -66420,7 +66426,7 @@ var ts;
|
|
|
66420
66426
|
return 0 /* Ternary.False */;
|
|
66421
66427
|
}
|
|
66422
66428
|
}
|
|
66423
|
-
var isPerformingCommonPropertyChecks = (relation !== comparableRelation ||
|
|
66429
|
+
var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
|
|
66424
66430
|
!(intersectionState & 2 /* IntersectionState.Target */) &&
|
|
66425
66431
|
source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
|
|
66426
66432
|
target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
|
|
@@ -66448,27 +66454,6 @@ var ts;
|
|
|
66448
66454
|
var result_7 = skipCaching ?
|
|
66449
66455
|
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
66450
66456
|
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
66451
|
-
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66452
|
-
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66453
|
-
// examples that all should be errors, but aren't without this extra property check:
|
|
66454
|
-
//
|
|
66455
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66456
|
-
//
|
|
66457
|
-
// declare let wrong: { a: { y: string } };
|
|
66458
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66459
|
-
//
|
|
66460
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
66461
|
-
// x = y; // Mismatched property in source intersection
|
|
66462
|
-
// }
|
|
66463
|
-
//
|
|
66464
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
66465
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
66466
|
-
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
66467
|
-
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 */); }))) {
|
|
66468
|
-
inPropertyCheck = true;
|
|
66469
|
-
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
|
|
66470
|
-
inPropertyCheck = false;
|
|
66471
|
-
}
|
|
66472
66457
|
if (result_7) {
|
|
66473
66458
|
return result_7;
|
|
66474
66459
|
}
|
|
@@ -66580,7 +66565,7 @@ var ts;
|
|
|
66580
66565
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66581
66566
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66582
66567
|
}
|
|
66583
|
-
var
|
|
66568
|
+
var _loop_20 = function (prop) {
|
|
66584
66569
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66585
66570
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66586
66571
|
if (reportErrors) {
|
|
@@ -66643,9 +66628,9 @@ var ts;
|
|
|
66643
66628
|
};
|
|
66644
66629
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66645
66630
|
var prop = _b[_i];
|
|
66646
|
-
var
|
|
66647
|
-
if (typeof
|
|
66648
|
-
return
|
|
66631
|
+
var state_6 = _loop_20(prop);
|
|
66632
|
+
if (typeof state_6 === "object")
|
|
66633
|
+
return state_6.value;
|
|
66649
66634
|
}
|
|
66650
66635
|
return false;
|
|
66651
66636
|
}
|
|
@@ -66866,8 +66851,7 @@ var ts;
|
|
|
66866
66851
|
if (overflow) {
|
|
66867
66852
|
return 0 /* Ternary.False */;
|
|
66868
66853
|
}
|
|
66869
|
-
var
|
|
66870
|
-
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66854
|
+
var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66871
66855
|
var entry = relation.get(id);
|
|
66872
66856
|
if (entry !== undefined) {
|
|
66873
66857
|
if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
|
|
@@ -66897,7 +66881,7 @@ var ts;
|
|
|
66897
66881
|
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
66898
66882
|
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
66899
66883
|
// were unconstrained.
|
|
66900
|
-
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target,
|
|
66884
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
66901
66885
|
for (var i = 0; i < maybeCount; i++) {
|
|
66902
66886
|
// If source and target are already being compared, consider them related with assumptions
|
|
66903
66887
|
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
@@ -66984,7 +66968,7 @@ var ts;
|
|
|
66984
66968
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66985
66969
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66986
66970
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66987
|
-
if (
|
|
66971
|
+
if (relation !== identityRelation) {
|
|
66988
66972
|
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66989
66973
|
// the constituents. When an intersection type contains instantiable types with union type
|
|
66990
66974
|
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
@@ -66998,10 +66982,33 @@ var ts;
|
|
|
66998
66982
|
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66999
66983
|
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
67000
66984
|
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
67001
|
-
|
|
67002
|
-
|
|
67003
|
-
|
|
67004
|
-
|
|
66985
|
+
if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
|
|
66986
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
|
|
66987
|
+
if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66988
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66989
|
+
result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
66990
|
+
}
|
|
66991
|
+
}
|
|
66992
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66993
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66994
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
66995
|
+
//
|
|
66996
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66997
|
+
//
|
|
66998
|
+
// declare let wrong: { a: { y: string } };
|
|
66999
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
67000
|
+
//
|
|
67001
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
67002
|
+
// x = y; // Mismatched property in source intersection
|
|
67003
|
+
// }
|
|
67004
|
+
//
|
|
67005
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
67006
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
67007
|
+
if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
|
|
67008
|
+
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 */); }))) {
|
|
67009
|
+
inPropertyCheck = true;
|
|
67010
|
+
result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67011
|
+
inPropertyCheck = false;
|
|
67005
67012
|
}
|
|
67006
67013
|
}
|
|
67007
67014
|
if (result) {
|
|
@@ -67010,9 +67017,6 @@ var ts;
|
|
|
67010
67017
|
return result;
|
|
67011
67018
|
}
|
|
67012
67019
|
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
67013
|
-
if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
|
|
67014
|
-
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67015
|
-
}
|
|
67016
67020
|
var result;
|
|
67017
67021
|
var originalErrorInfo;
|
|
67018
67022
|
var varianceCheckFailed = false;
|
|
@@ -67636,11 +67640,11 @@ var ts;
|
|
|
67636
67640
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67637
67641
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67638
67642
|
var matchingTypes = [];
|
|
67639
|
-
var
|
|
67643
|
+
var _loop_21 = function (combination) {
|
|
67640
67644
|
var hasMatch = false;
|
|
67641
67645
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67642
67646
|
var type = _d[_c];
|
|
67643
|
-
var
|
|
67647
|
+
var _loop_22 = function (i) {
|
|
67644
67648
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67645
67649
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67646
67650
|
if (!targetProperty)
|
|
@@ -67656,8 +67660,8 @@ var ts;
|
|
|
67656
67660
|
}
|
|
67657
67661
|
};
|
|
67658
67662
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67659
|
-
var
|
|
67660
|
-
switch (
|
|
67663
|
+
var state_8 = _loop_22(i);
|
|
67664
|
+
switch (state_8) {
|
|
67661
67665
|
case "continue-outer": continue outer;
|
|
67662
67666
|
}
|
|
67663
67667
|
}
|
|
@@ -67670,9 +67674,9 @@ var ts;
|
|
|
67670
67674
|
};
|
|
67671
67675
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67672
67676
|
var combination = discriminantCombinations_1[_a];
|
|
67673
|
-
var
|
|
67674
|
-
if (typeof
|
|
67675
|
-
return
|
|
67677
|
+
var state_7 = _loop_21(combination);
|
|
67678
|
+
if (typeof state_7 === "object")
|
|
67679
|
+
return state_7.value;
|
|
67676
67680
|
}
|
|
67677
67681
|
// Compare the remaining non-discriminant properties of each match.
|
|
67678
67682
|
var result = -1 /* Ternary.True */;
|
|
@@ -68377,7 +68381,7 @@ var ts;
|
|
|
68377
68381
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
68378
68382
|
links.variances = ts.emptyArray;
|
|
68379
68383
|
var variances = [];
|
|
68380
|
-
var
|
|
68384
|
+
var _loop_23 = function (tp) {
|
|
68381
68385
|
var modifiers = getVarianceModifiers(tp);
|
|
68382
68386
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68383
68387
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68415,7 +68419,7 @@ var ts;
|
|
|
68415
68419
|
};
|
|
68416
68420
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68417
68421
|
var tp = typeParameters_2[_i];
|
|
68418
|
-
|
|
68422
|
+
_loop_23(tp);
|
|
68419
68423
|
}
|
|
68420
68424
|
links.variances = variances;
|
|
68421
68425
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -70373,7 +70377,7 @@ var ts;
|
|
|
70373
70377
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70374
70378
|
// succeed. That would be a pointless and confusing outcome.
|
|
70375
70379
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70376
|
-
var
|
|
70380
|
+
var _loop_24 = function (i) {
|
|
70377
70381
|
var source_1 = matches ? matches[i] : neverType;
|
|
70378
70382
|
var target_3 = types[i];
|
|
70379
70383
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70423,7 +70427,7 @@ var ts;
|
|
|
70423
70427
|
inferFromTypes(source_1, target_3);
|
|
70424
70428
|
};
|
|
70425
70429
|
for (var i = 0; i < types.length; i++) {
|
|
70426
|
-
|
|
70430
|
+
_loop_24(i);
|
|
70427
70431
|
}
|
|
70428
70432
|
}
|
|
70429
70433
|
}
|
|
@@ -70952,7 +70956,7 @@ var ts;
|
|
|
70952
70956
|
function mapTypesByKeyProperty(types, name) {
|
|
70953
70957
|
var map = new ts.Map();
|
|
70954
70958
|
var count = 0;
|
|
70955
|
-
var
|
|
70959
|
+
var _loop_25 = function (type) {
|
|
70956
70960
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70957
70961
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70958
70962
|
if (discriminant) {
|
|
@@ -70978,9 +70982,9 @@ var ts;
|
|
|
70978
70982
|
};
|
|
70979
70983
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70980
70984
|
var type = types_15[_i];
|
|
70981
|
-
var
|
|
70982
|
-
if (typeof
|
|
70983
|
-
return
|
|
70985
|
+
var state_9 = _loop_25(type);
|
|
70986
|
+
if (typeof state_9 === "object")
|
|
70987
|
+
return state_9.value;
|
|
70984
70988
|
}
|
|
70985
70989
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70986
70990
|
}
|
|
@@ -77436,7 +77440,7 @@ var ts;
|
|
|
77436
77440
|
if (spreadIndex >= 0) {
|
|
77437
77441
|
// Create synthetic arguments from spreads of tuple types.
|
|
77438
77442
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77439
|
-
var
|
|
77443
|
+
var _loop_26 = function (i) {
|
|
77440
77444
|
var arg = args[i];
|
|
77441
77445
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77442
77446
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77453,7 +77457,7 @@ var ts;
|
|
|
77453
77457
|
}
|
|
77454
77458
|
};
|
|
77455
77459
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77456
|
-
|
|
77460
|
+
_loop_26(i);
|
|
77457
77461
|
}
|
|
77458
77462
|
return effectiveArgs_1;
|
|
77459
77463
|
}
|
|
@@ -77782,7 +77786,7 @@ var ts;
|
|
|
77782
77786
|
var min_3 = Number.MAX_VALUE;
|
|
77783
77787
|
var minIndex = 0;
|
|
77784
77788
|
var i_1 = 0;
|
|
77785
|
-
var
|
|
77789
|
+
var _loop_27 = function (c) {
|
|
77786
77790
|
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)); };
|
|
77787
77791
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77788
77792
|
if (diags_2) {
|
|
@@ -77800,7 +77804,7 @@ var ts;
|
|
|
77800
77804
|
};
|
|
77801
77805
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77802
77806
|
var c = candidatesForArgumentError_1[_a];
|
|
77803
|
-
|
|
77807
|
+
_loop_27(c);
|
|
77804
77808
|
}
|
|
77805
77809
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77806
77810
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77958,7 +77962,7 @@ var ts;
|
|
|
77958
77962
|
}
|
|
77959
77963
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77960
77964
|
var parameters = [];
|
|
77961
|
-
var
|
|
77965
|
+
var _loop_28 = function (i) {
|
|
77962
77966
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77963
77967
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77964
77968
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77966,7 +77970,7 @@ var ts;
|
|
|
77966
77970
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77967
77971
|
};
|
|
77968
77972
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77969
|
-
|
|
77973
|
+
_loop_28(i);
|
|
77970
77974
|
}
|
|
77971
77975
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77972
77976
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -82024,7 +82028,7 @@ var ts;
|
|
|
82024
82028
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
82025
82029
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
82026
82030
|
var indexSignatureMap_1 = new ts.Map();
|
|
82027
|
-
var
|
|
82031
|
+
var _loop_29 = function (declaration) {
|
|
82028
82032
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
82029
82033
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
82030
82034
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -82039,7 +82043,7 @@ var ts;
|
|
|
82039
82043
|
};
|
|
82040
82044
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
82041
82045
|
var declaration = _a[_i];
|
|
82042
|
-
|
|
82046
|
+
_loop_29(declaration);
|
|
82043
82047
|
}
|
|
82044
82048
|
indexSignatureMap_1.forEach(function (entry) {
|
|
82045
82049
|
if (entry.declarations.length > 1) {
|
|
@@ -82316,7 +82320,7 @@ var ts;
|
|
|
82316
82320
|
}
|
|
82317
82321
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
82318
82322
|
if (symbol) {
|
|
82319
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82323
|
+
if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82320
82324
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
82321
82325
|
}
|
|
82322
82326
|
if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
|
|
@@ -83694,7 +83698,7 @@ var ts;
|
|
|
83694
83698
|
}
|
|
83695
83699
|
function errorUnusedLocal(declaration, name, addDiagnostic) {
|
|
83696
83700
|
var node = ts.getNameOfDeclaration(declaration) || declaration;
|
|
83697
|
-
var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83701
|
+
var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83698
83702
|
addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
|
|
83699
83703
|
}
|
|
83700
83704
|
function isIdentifierThatStartsWithUnderscore(node) {
|
|
@@ -85648,7 +85652,7 @@ var ts;
|
|
|
85648
85652
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85649
85653
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85650
85654
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85651
|
-
var
|
|
85655
|
+
var _loop_30 = function (info) {
|
|
85652
85656
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85653
85657
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85654
85658
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85665,7 +85669,7 @@ var ts;
|
|
|
85665
85669
|
};
|
|
85666
85670
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85667
85671
|
var info = indexInfos_9[_i];
|
|
85668
|
-
|
|
85672
|
+
_loop_30(info);
|
|
85669
85673
|
}
|
|
85670
85674
|
}
|
|
85671
85675
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85673,7 +85677,7 @@ var ts;
|
|
|
85673
85677
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85674
85678
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85675
85679
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85676
|
-
var
|
|
85680
|
+
var _loop_31 = function (info) {
|
|
85677
85681
|
if (info === checkInfo)
|
|
85678
85682
|
return "continue";
|
|
85679
85683
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85688,7 +85692,7 @@ var ts;
|
|
|
85688
85692
|
};
|
|
85689
85693
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85690
85694
|
var info = indexInfos_10[_i];
|
|
85691
|
-
|
|
85695
|
+
_loop_31(info);
|
|
85692
85696
|
}
|
|
85693
85697
|
}
|
|
85694
85698
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85743,7 +85747,7 @@ var ts;
|
|
|
85743
85747
|
}
|
|
85744
85748
|
else {
|
|
85745
85749
|
ts.forEach(jsdocParameters, function (_a, index) {
|
|
85746
|
-
var name = _a.name;
|
|
85750
|
+
var name = _a.name, isNameFirst = _a.isNameFirst;
|
|
85747
85751
|
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
85748
85752
|
return;
|
|
85749
85753
|
}
|
|
@@ -85753,7 +85757,9 @@ var ts;
|
|
|
85753
85757
|
}
|
|
85754
85758
|
}
|
|
85755
85759
|
else {
|
|
85756
|
-
|
|
85760
|
+
if (!isNameFirst) {
|
|
85761
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
85762
|
+
}
|
|
85757
85763
|
}
|
|
85758
85764
|
});
|
|
85759
85765
|
}
|
|
@@ -86008,7 +86014,7 @@ var ts;
|
|
|
86008
86014
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
86009
86015
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
86010
86016
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
86011
|
-
var
|
|
86017
|
+
var _loop_32 = function (member) {
|
|
86012
86018
|
if (ts.hasAmbientModifier(member)) {
|
|
86013
86019
|
return "continue";
|
|
86014
86020
|
}
|
|
@@ -86025,7 +86031,7 @@ var ts;
|
|
|
86025
86031
|
};
|
|
86026
86032
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86027
86033
|
var member = _a[_i];
|
|
86028
|
-
|
|
86034
|
+
_loop_32(member);
|
|
86029
86035
|
}
|
|
86030
86036
|
}
|
|
86031
86037
|
/**
|
|
@@ -86113,7 +86119,7 @@ var ts;
|
|
|
86113
86119
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
86114
86120
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
86115
86121
|
var issuedMemberError = false;
|
|
86116
|
-
var
|
|
86122
|
+
var _loop_33 = function (member) {
|
|
86117
86123
|
if (ts.isStatic(member)) {
|
|
86118
86124
|
return "continue";
|
|
86119
86125
|
}
|
|
@@ -86132,7 +86138,7 @@ var ts;
|
|
|
86132
86138
|
};
|
|
86133
86139
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86134
86140
|
var member = _a[_i];
|
|
86135
|
-
|
|
86141
|
+
_loop_33(member);
|
|
86136
86142
|
}
|
|
86137
86143
|
if (!issuedMemberError) {
|
|
86138
86144
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -86203,7 +86209,7 @@ var ts;
|
|
|
86203
86209
|
var _a, _b, _c, _d;
|
|
86204
86210
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
86205
86211
|
var baseProperties = getPropertiesOfType(baseType);
|
|
86206
|
-
var
|
|
86212
|
+
var _loop_34 = function (baseProperty) {
|
|
86207
86213
|
var base = getTargetSymbol(baseProperty);
|
|
86208
86214
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
86209
86215
|
return "continue";
|
|
@@ -86313,8 +86319,8 @@ var ts;
|
|
|
86313
86319
|
};
|
|
86314
86320
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86315
86321
|
var baseProperty = baseProperties_1[_i];
|
|
86316
|
-
var
|
|
86317
|
-
switch (
|
|
86322
|
+
var state_10 = _loop_34(baseProperty);
|
|
86323
|
+
switch (state_10) {
|
|
86318
86324
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86319
86325
|
}
|
|
86320
86326
|
}
|
|
@@ -88024,29 +88030,9 @@ var ts;
|
|
|
88024
88030
|
}
|
|
88025
88031
|
function isTypeDeclarationName(name) {
|
|
88026
88032
|
return name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
88027
|
-
isTypeDeclaration(name.parent) &&
|
|
88033
|
+
ts.isTypeDeclaration(name.parent) &&
|
|
88028
88034
|
ts.getNameOfDeclaration(name.parent) === name;
|
|
88029
88035
|
}
|
|
88030
|
-
function isTypeDeclaration(node) {
|
|
88031
|
-
switch (node.kind) {
|
|
88032
|
-
case 165 /* SyntaxKind.TypeParameter */:
|
|
88033
|
-
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
88034
|
-
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
88035
|
-
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
88036
|
-
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
88037
|
-
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
88038
|
-
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
88039
|
-
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
88040
|
-
return true;
|
|
88041
|
-
case 270 /* SyntaxKind.ImportClause */:
|
|
88042
|
-
return node.isTypeOnly;
|
|
88043
|
-
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88044
|
-
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88045
|
-
return node.parent.parent.isTypeOnly;
|
|
88046
|
-
default:
|
|
88047
|
-
return false;
|
|
88048
|
-
}
|
|
88049
|
-
}
|
|
88050
88036
|
// True if the given identifier is part of a type reference
|
|
88051
88037
|
function isTypeReferenceIdentifier(node) {
|
|
88052
88038
|
while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
|
|
@@ -88479,7 +88465,7 @@ var ts;
|
|
|
88479
88465
|
var baseType = ts.firstOrUndefined(getBaseTypes(classType));
|
|
88480
88466
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
|
88481
88467
|
}
|
|
88482
|
-
if (isTypeDeclaration(node)) {
|
|
88468
|
+
if (ts.isTypeDeclaration(node)) {
|
|
88483
88469
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
88484
88470
|
var symbol = getSymbolOfNode(node);
|
|
88485
88471
|
return getDeclaredTypeOfSymbol(symbol);
|
|
@@ -125165,7 +125151,7 @@ var ts;
|
|
|
125165
125151
|
});
|
|
125166
125152
|
// Sort by paths closest to importing file Name directory
|
|
125167
125153
|
var sortedPaths = [];
|
|
125168
|
-
var
|
|
125154
|
+
var _loop_35 = function (directory) {
|
|
125169
125155
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
125170
125156
|
var pathsInDirectory;
|
|
125171
125157
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -125189,9 +125175,9 @@ var ts;
|
|
|
125189
125175
|
};
|
|
125190
125176
|
var out_directory_1;
|
|
125191
125177
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
125192
|
-
var
|
|
125178
|
+
var state_11 = _loop_35(directory);
|
|
125193
125179
|
directory = out_directory_1;
|
|
125194
|
-
if (
|
|
125180
|
+
if (state_11 === "break")
|
|
125195
125181
|
break;
|
|
125196
125182
|
}
|
|
125197
125183
|
if (allFileNames.size) {
|
|
@@ -125260,7 +125246,7 @@ var ts;
|
|
|
125260
125246
|
}
|
|
125261
125247
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125262
125248
|
for (var key in paths) {
|
|
125263
|
-
var
|
|
125249
|
+
var _loop_36 = function (patternText_1) {
|
|
125264
125250
|
var pattern = ts.normalizePath(patternText_1);
|
|
125265
125251
|
var indexOfStar = pattern.indexOf("*");
|
|
125266
125252
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125327,9 +125313,9 @@ var ts;
|
|
|
125327
125313
|
};
|
|
125328
125314
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125329
125315
|
var patternText_1 = _a[_i];
|
|
125330
|
-
var
|
|
125331
|
-
if (typeof
|
|
125332
|
-
return
|
|
125316
|
+
var state_12 = _loop_36(patternText_1);
|
|
125317
|
+
if (typeof state_12 === "object")
|
|
125318
|
+
return state_12.value;
|
|
125333
125319
|
}
|
|
125334
125320
|
}
|
|
125335
125321
|
function validateEnding(_a) {
|
|
@@ -132440,6 +132426,10 @@ var ts;
|
|
|
132440
132426
|
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
|
|
132441
132427
|
}
|
|
132442
132428
|
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
132429
|
+
function isSourceFileFromLibrary(program, node) {
|
|
132430
|
+
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
132431
|
+
}
|
|
132432
|
+
ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
|
|
132443
132433
|
// #endregion
|
|
132444
132434
|
})(ts || (ts = {}));
|
|
132445
132435
|
/*@internal*/
|
|
@@ -157547,6 +157537,143 @@ var ts;
|
|
|
157547
157537
|
})(ts || (ts = {}));
|
|
157548
157538
|
/* @internal */
|
|
157549
157539
|
var ts;
|
|
157540
|
+
(function (ts) {
|
|
157541
|
+
var codefix;
|
|
157542
|
+
(function (codefix) {
|
|
157543
|
+
var fixId = "fixImportNonExportedMember";
|
|
157544
|
+
var errorCodes = [
|
|
157545
|
+
ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
|
|
157546
|
+
];
|
|
157547
|
+
codefix.registerCodeFix({
|
|
157548
|
+
errorCodes: errorCodes,
|
|
157549
|
+
fixIds: [fixId],
|
|
157550
|
+
getCodeActions: function (context) {
|
|
157551
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
157552
|
+
var info = getInfo(sourceFile, span.start, program);
|
|
157553
|
+
if (info === undefined)
|
|
157554
|
+
return undefined;
|
|
157555
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
|
|
157556
|
+
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)];
|
|
157557
|
+
},
|
|
157558
|
+
getAllCodeActions: function (context) {
|
|
157559
|
+
var program = context.program;
|
|
157560
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
157561
|
+
var exports = new ts.Map();
|
|
157562
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
157563
|
+
var info = getInfo(diag.file, diag.start, program);
|
|
157564
|
+
if (info === undefined)
|
|
157565
|
+
return undefined;
|
|
157566
|
+
var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
|
|
157567
|
+
if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
|
|
157568
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157569
|
+
}
|
|
157570
|
+
else {
|
|
157571
|
+
var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
|
|
157572
|
+
if (exportName.isTypeOnly) {
|
|
157573
|
+
moduleExports.typeOnlyExports.push(exportName);
|
|
157574
|
+
}
|
|
157575
|
+
else {
|
|
157576
|
+
moduleExports.exports.push(exportName);
|
|
157577
|
+
}
|
|
157578
|
+
exports.set(moduleSourceFile, moduleExports);
|
|
157579
|
+
}
|
|
157580
|
+
});
|
|
157581
|
+
exports.forEach(function (moduleExports, moduleSourceFile) {
|
|
157582
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
|
|
157583
|
+
if (exportDeclaration && exportDeclaration.isTypeOnly) {
|
|
157584
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
|
|
157585
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
|
|
157586
|
+
}
|
|
157587
|
+
else {
|
|
157588
|
+
doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
|
|
157589
|
+
}
|
|
157590
|
+
});
|
|
157591
|
+
}));
|
|
157592
|
+
}
|
|
157593
|
+
});
|
|
157594
|
+
function getInfo(sourceFile, pos, program) {
|
|
157595
|
+
var _a;
|
|
157596
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
157597
|
+
if (ts.isIdentifier(token)) {
|
|
157598
|
+
var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
|
|
157599
|
+
if (importDeclaration === undefined)
|
|
157600
|
+
return undefined;
|
|
157601
|
+
var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
|
157602
|
+
if (moduleSpecifier === undefined)
|
|
157603
|
+
return undefined;
|
|
157604
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
|
|
157605
|
+
if (resolvedModule === undefined)
|
|
157606
|
+
return undefined;
|
|
157607
|
+
var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
157608
|
+
if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
|
|
157609
|
+
return undefined;
|
|
157610
|
+
var moduleSymbol = moduleSourceFile.symbol;
|
|
157611
|
+
var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
|
|
157612
|
+
if (locals === undefined)
|
|
157613
|
+
return undefined;
|
|
157614
|
+
var localSymbol = locals.get(token.escapedText);
|
|
157615
|
+
if (localSymbol === undefined)
|
|
157616
|
+
return undefined;
|
|
157617
|
+
var node = getNodeOfSymbol(localSymbol);
|
|
157618
|
+
if (node === undefined)
|
|
157619
|
+
return undefined;
|
|
157620
|
+
var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
|
|
157621
|
+
return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
|
|
157622
|
+
}
|
|
157623
|
+
return undefined;
|
|
157624
|
+
}
|
|
157625
|
+
function doChange(changes, program, _a) {
|
|
157626
|
+
var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
|
|
157627
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
157628
|
+
if (exportDeclaration) {
|
|
157629
|
+
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
157630
|
+
}
|
|
157631
|
+
else if (ts.canHaveExportModifier(node)) {
|
|
157632
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157633
|
+
}
|
|
157634
|
+
else {
|
|
157635
|
+
createExport(changes, program, moduleSourceFile, [exportName]);
|
|
157636
|
+
}
|
|
157637
|
+
}
|
|
157638
|
+
function doChanges(changes, program, sourceFile, moduleExports, node) {
|
|
157639
|
+
if (ts.length(moduleExports)) {
|
|
157640
|
+
if (node) {
|
|
157641
|
+
updateExport(changes, program, sourceFile, node, moduleExports);
|
|
157642
|
+
}
|
|
157643
|
+
else {
|
|
157644
|
+
createExport(changes, program, sourceFile, moduleExports);
|
|
157645
|
+
}
|
|
157646
|
+
}
|
|
157647
|
+
}
|
|
157648
|
+
function tryGetExportDeclaration(sourceFile, isTypeOnly) {
|
|
157649
|
+
var predicate = function (node) {
|
|
157650
|
+
return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
|
|
157651
|
+
};
|
|
157652
|
+
return ts.findLast(sourceFile.statements, predicate);
|
|
157653
|
+
}
|
|
157654
|
+
function updateExport(changes, program, sourceFile, node, names) {
|
|
157655
|
+
var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
|
|
157656
|
+
var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
|
|
157657
|
+
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));
|
|
157658
|
+
}
|
|
157659
|
+
function createExport(changes, program, sourceFile, names) {
|
|
157660
|
+
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
|
|
157661
|
+
}
|
|
157662
|
+
function createExportSpecifiers(names, allowTypeModifier) {
|
|
157663
|
+
return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
|
|
157664
|
+
}
|
|
157665
|
+
function getNodeOfSymbol(symbol) {
|
|
157666
|
+
if (symbol.valueDeclaration === undefined) {
|
|
157667
|
+
return ts.firstOrUndefined(symbol.declarations);
|
|
157668
|
+
}
|
|
157669
|
+
var declaration = symbol.valueDeclaration;
|
|
157670
|
+
var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
|
|
157671
|
+
return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
157672
|
+
}
|
|
157673
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
157674
|
+
})(ts || (ts = {}));
|
|
157675
|
+
/* @internal */
|
|
157676
|
+
var ts;
|
|
157550
157677
|
(function (ts) {
|
|
157551
157678
|
var codefix;
|
|
157552
157679
|
(function (codefix) {
|
|
@@ -158077,7 +158204,7 @@ var ts;
|
|
|
158077
158204
|
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
|
|
158078
158205
|
if (argIndex < 0)
|
|
158079
158206
|
return undefined;
|
|
158080
|
-
var signature =
|
|
158207
|
+
var signature = checker.getResolvedSignature(parent.parent);
|
|
158081
158208
|
if (!(signature && signature.declaration && signature.parameters[argIndex]))
|
|
158082
158209
|
return undefined;
|
|
158083
158210
|
var param = signature.parameters[argIndex].valueDeclaration;
|
|
@@ -158124,13 +158251,13 @@ var ts;
|
|
|
158124
158251
|
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
|
|
158125
158252
|
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
|
|
158126
158253
|
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
|
|
158127
|
-
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158254
|
+
if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158128
158255
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
|
|
158129
158256
|
}
|
|
158130
158257
|
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
|
|
158131
158258
|
if (sourceFile.commonJsModuleIndicator)
|
|
158132
158259
|
return undefined;
|
|
158133
|
-
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158260
|
+
if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158134
158261
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
|
|
158135
158262
|
}
|
|
158136
158263
|
}
|
|
@@ -158140,7 +158267,7 @@ var ts;
|
|
|
158140
158267
|
return undefined;
|
|
158141
158268
|
// Prefer to change the class instead of the interface if they are merged
|
|
158142
158269
|
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
158143
|
-
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158270
|
+
if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158144
158271
|
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
158145
158272
|
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
158146
158273
|
return undefined;
|
|
@@ -158152,14 +158279,11 @@ var ts;
|
|
|
158152
158279
|
return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
158153
158280
|
}
|
|
158154
158281
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
158155
|
-
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158282
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158156
158283
|
return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
|
|
158157
158284
|
}
|
|
158158
158285
|
return undefined;
|
|
158159
158286
|
}
|
|
158160
|
-
function isSourceFileFromLibrary(program, node) {
|
|
158161
|
-
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
158162
|
-
}
|
|
158163
158287
|
function getActionsForMissingMemberDeclaration(context, info) {
|
|
158164
158288
|
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
|
|
158165
158289
|
createActionsForAddMissingMemberInTypeScriptFile(context, info);
|
|
@@ -163585,8 +163709,8 @@ var ts;
|
|
|
163585
163709
|
var i = 0;
|
|
163586
163710
|
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
|
|
163587
163711
|
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
|
|
163588
|
-
var description = functionExtraction.description;
|
|
163589
163712
|
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
163713
|
+
var description = functionExtraction.description;
|
|
163590
163714
|
if (functionExtraction.errors.length === 0) {
|
|
163591
163715
|
// Don't issue refactorings with duplicated names.
|
|
163592
163716
|
// Scopes come back in "innermost first" order, so extractions will
|
|
@@ -163610,15 +163734,15 @@ var ts;
|
|
|
163610
163734
|
}
|
|
163611
163735
|
}
|
|
163612
163736
|
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
163737
|
+
var description = constantExtraction.description;
|
|
163613
163738
|
if (constantExtraction.errors.length === 0) {
|
|
163614
163739
|
// Don't issue refactorings with duplicated names.
|
|
163615
163740
|
// Scopes come back in "innermost first" order, so extractions will
|
|
163616
163741
|
// preferentially go into nearer scopes
|
|
163617
|
-
|
|
163618
|
-
|
|
163619
|
-
usedConstantNames.set(description_1, true);
|
|
163742
|
+
if (!usedConstantNames.has(description)) {
|
|
163743
|
+
usedConstantNames.set(description, true);
|
|
163620
163744
|
constantActions.push({
|
|
163621
|
-
description:
|
|
163745
|
+
description: description,
|
|
163622
163746
|
name: "constant_scope_".concat(i),
|
|
163623
163747
|
kind: extractConstantAction.kind
|
|
163624
163748
|
});
|