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