typescript 4.9.0-dev.20221013 → 4.9.0-dev.20221015
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 +145 -128
- package/lib/tsserver.js +317 -168
- package/lib/tsserverlibrary.js +317 -168
- package/lib/typescript.js +317 -168
- package/lib/typescriptServices.js +317 -168
- package/lib/typingsInstaller.js +166 -155
- 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.20221015");
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -9604,6 +9604,10 @@ var ts;
|
|
|
9604
9604
|
Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"),
|
|
9605
9605
|
Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"),
|
|
9606
9606
|
Project_0_is_out_of_date_because_there_was_error_reading_file_1: diag(6401, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_there_was_error_reading_file_1_6401", "Project '{0}' is out of date because there was error reading file '{1}'"),
|
|
9607
|
+
Resolving_in_0_mode_with_conditions_1: diag(6402, ts.DiagnosticCategory.Message, "Resolving_in_0_mode_with_conditions_1_6402", "Resolving in {0} mode with conditions {1}."),
|
|
9608
|
+
Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
|
|
9609
|
+
Using_0_subpath_1_with_target_2: diag(6404, ts.DiagnosticCategory.Message, "Using_0_subpath_1_with_target_2_6404", "Using '{0}' subpath '{1}' with target '{2}'."),
|
|
9610
|
+
Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
|
|
9607
9611
|
The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
|
|
9608
9612
|
The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
|
|
9609
9613
|
The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
|
|
@@ -9920,6 +9924,8 @@ var ts;
|
|
|
9920
9924
|
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
9925
|
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9922
9926
|
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9927
|
+
Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
9928
|
+
Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
9923
9929
|
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
9930
|
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
9931
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -21680,6 +21686,32 @@ var ts;
|
|
|
21680
21686
|
return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21681
21687
|
}
|
|
21682
21688
|
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21689
|
+
function isTypeDeclaration(node) {
|
|
21690
|
+
switch (node.kind) {
|
|
21691
|
+
case 165 /* SyntaxKind.TypeParameter */:
|
|
21692
|
+
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
21693
|
+
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
21694
|
+
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
21695
|
+
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
21696
|
+
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
21697
|
+
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
21698
|
+
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
21699
|
+
return true;
|
|
21700
|
+
case 270 /* SyntaxKind.ImportClause */:
|
|
21701
|
+
return node.isTypeOnly;
|
|
21702
|
+
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
21703
|
+
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
21704
|
+
return node.parent.parent.isTypeOnly;
|
|
21705
|
+
default:
|
|
21706
|
+
return false;
|
|
21707
|
+
}
|
|
21708
|
+
}
|
|
21709
|
+
ts.isTypeDeclaration = isTypeDeclaration;
|
|
21710
|
+
function canHaveExportModifier(node) {
|
|
21711
|
+
return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
|
|
21712
|
+
|| ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
|
|
21713
|
+
}
|
|
21714
|
+
ts.canHaveExportModifier = canHaveExportModifier;
|
|
21683
21715
|
})(ts || (ts = {}));
|
|
21684
21716
|
/* @internal */
|
|
21685
21717
|
var ts;
|
|
@@ -44304,6 +44336,9 @@ var ts;
|
|
|
44304
44336
|
requestContainingDirectory: containingDirectory,
|
|
44305
44337
|
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
44306
44338
|
};
|
|
44339
|
+
if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
|
|
44340
|
+
trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
|
|
44341
|
+
}
|
|
44307
44342
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
44308
44343
|
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
|
|
44309
44344
|
function tryResolve(extensions) {
|
|
@@ -44893,7 +44928,7 @@ var ts;
|
|
|
44893
44928
|
}
|
|
44894
44929
|
if (mainExport) {
|
|
44895
44930
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
44896
|
-
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
44931
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
|
|
44897
44932
|
}
|
|
44898
44933
|
}
|
|
44899
44934
|
else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
|
|
@@ -44973,7 +45008,7 @@ var ts;
|
|
|
44973
45008
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44974
45009
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
44975
45010
|
var target = lookupTable[moduleName];
|
|
44976
|
-
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
45011
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
|
|
44977
45012
|
}
|
|
44978
45013
|
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
|
|
44979
45014
|
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
@@ -44982,17 +45017,17 @@ var ts;
|
|
|
44982
45017
|
var target = lookupTable[potentialTarget];
|
|
44983
45018
|
var starPos = potentialTarget.indexOf("*");
|
|
44984
45019
|
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
44985
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45020
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44986
45021
|
}
|
|
44987
45022
|
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
44988
45023
|
var target = lookupTable[potentialTarget];
|
|
44989
45024
|
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
44990
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45025
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44991
45026
|
}
|
|
44992
45027
|
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
44993
45028
|
var target = lookupTable[potentialTarget];
|
|
44994
45029
|
var subpath = moduleName.substring(potentialTarget.length);
|
|
44995
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
45030
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
|
|
44996
45031
|
}
|
|
44997
45032
|
}
|
|
44998
45033
|
function matchesPatternWithTrailer(target, name) {
|
|
@@ -45009,7 +45044,7 @@ var ts;
|
|
|
45009
45044
|
*/
|
|
45010
45045
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
45011
45046
|
return loadModuleFromTargetImportOrExport;
|
|
45012
|
-
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
45047
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
|
|
45013
45048
|
if (typeof target === "string") {
|
|
45014
45049
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
45015
45050
|
if (state.traceEnabled) {
|
|
@@ -45020,6 +45055,8 @@ var ts;
|
|
|
45020
45055
|
if (!ts.startsWith(target, "./")) {
|
|
45021
45056
|
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
45022
45057
|
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
45058
|
+
traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
|
|
45059
|
+
traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
|
|
45023
45060
|
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
45024
45061
|
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
45025
45062
|
}
|
|
@@ -45046,6 +45083,9 @@ var ts;
|
|
|
45046
45083
|
}
|
|
45047
45084
|
return toSearchResult(/*value*/ undefined);
|
|
45048
45085
|
}
|
|
45086
|
+
if (state.traceEnabled) {
|
|
45087
|
+
trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
|
|
45088
|
+
}
|
|
45049
45089
|
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
45050
45090
|
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
45051
45091
|
if (inputLink)
|
|
@@ -45055,14 +45095,18 @@ var ts;
|
|
|
45055
45095
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
45056
45096
|
if (!Array.isArray(target)) {
|
|
45057
45097
|
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
45058
|
-
var
|
|
45059
|
-
if (
|
|
45060
|
-
|
|
45061
|
-
var
|
|
45098
|
+
var condition = _a[_i];
|
|
45099
|
+
if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
|
45100
|
+
traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
|
45101
|
+
var subTarget = target[condition];
|
|
45102
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
|
|
45062
45103
|
if (result) {
|
|
45063
45104
|
return result;
|
|
45064
45105
|
}
|
|
45065
45106
|
}
|
|
45107
|
+
else {
|
|
45108
|
+
traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
|
|
45109
|
+
}
|
|
45066
45110
|
}
|
|
45067
45111
|
return undefined;
|
|
45068
45112
|
}
|
|
@@ -45075,7 +45119,7 @@ var ts;
|
|
|
45075
45119
|
}
|
|
45076
45120
|
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
45077
45121
|
var elem = target_2[_b];
|
|
45078
|
-
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
45122
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
|
|
45079
45123
|
if (result) {
|
|
45080
45124
|
return result;
|
|
45081
45125
|
}
|
|
@@ -45491,6 +45535,15 @@ var ts;
|
|
|
45491
45535
|
function toSearchResult(value) {
|
|
45492
45536
|
return value !== undefined ? { value: value } : undefined;
|
|
45493
45537
|
}
|
|
45538
|
+
function traceIfEnabled(state, diagnostic) {
|
|
45539
|
+
var args = [];
|
|
45540
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
45541
|
+
args[_i - 2] = arguments[_i];
|
|
45542
|
+
}
|
|
45543
|
+
if (state.traceEnabled) {
|
|
45544
|
+
trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
|
|
45545
|
+
}
|
|
45546
|
+
}
|
|
45494
45547
|
})(ts || (ts = {}));
|
|
45495
45548
|
/* @internal */
|
|
45496
45549
|
var ts;
|
|
@@ -49082,8 +49135,6 @@ var ts;
|
|
|
49082
49135
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
49083
49136
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
49084
49137
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
49085
|
-
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
49086
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
49087
49138
|
})(IntersectionState || (IntersectionState = {}));
|
|
49088
49139
|
var RecursionFlags;
|
|
49089
49140
|
(function (RecursionFlags) {
|
|
@@ -55425,7 +55476,7 @@ var ts;
|
|
|
55425
55476
|
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
|
|
55426
55477
|
var indices = ts.indicesOf(statements);
|
|
55427
55478
|
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]); })) {
|
|
55479
|
+
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
|
|
55429
55480
|
for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
|
|
55430
55481
|
var index_1 = associatedIndices_1[_i];
|
|
55431
55482
|
statements[index_1] = addExportModifier(statements[index_1]);
|
|
@@ -55459,15 +55510,6 @@ var ts;
|
|
|
55459
55510
|
}
|
|
55460
55511
|
return statements;
|
|
55461
55512
|
}
|
|
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
55513
|
function addExportModifier(node) {
|
|
55472
55514
|
var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
|
|
55473
55515
|
return ts.factory.updateModifiers(node, flags);
|
|
@@ -55714,7 +55756,7 @@ var ts;
|
|
|
55714
55756
|
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
55715
55757
|
if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
|
|
55716
55758
|
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
|
|
55717
|
-
canHaveExportModifier(node)) {
|
|
55759
|
+
ts.canHaveExportModifier(node)) {
|
|
55718
55760
|
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
|
|
55719
55761
|
newModifierFlags |= 1 /* ModifierFlags.Export */;
|
|
55720
55762
|
}
|
|
@@ -63841,18 +63883,23 @@ var ts;
|
|
|
63841
63883
|
var result;
|
|
63842
63884
|
var extraTypes;
|
|
63843
63885
|
var tailCount = 0;
|
|
63844
|
-
|
|
63886
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63887
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63888
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63889
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63890
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63891
|
+
while (true) {
|
|
63845
63892
|
if (tailCount === 1000) {
|
|
63846
63893
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63847
63894
|
result = errorType;
|
|
63848
|
-
|
|
63895
|
+
break;
|
|
63849
63896
|
}
|
|
63850
63897
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
63851
63898
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
63852
63899
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
63853
63900
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
63854
63901
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
63855
|
-
return
|
|
63902
|
+
return wildcardType;
|
|
63856
63903
|
}
|
|
63857
63904
|
var combinedMapper = void 0;
|
|
63858
63905
|
if (root.inferTypeParameters) {
|
|
@@ -63885,11 +63932,7 @@ var ts;
|
|
|
63885
63932
|
}
|
|
63886
63933
|
}
|
|
63887
63934
|
}
|
|
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; })) {
|
|
63935
|
+
if (!checkTypeInstantiable) {
|
|
63893
63936
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
63894
63937
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
63895
63938
|
// types rules (i.e. proper contravariance) for inferences.
|
|
@@ -63921,14 +63964,14 @@ var ts;
|
|
|
63921
63964
|
var newRoot = falseType_1.root;
|
|
63922
63965
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
63923
63966
|
root = newRoot;
|
|
63924
|
-
|
|
63967
|
+
continue;
|
|
63925
63968
|
}
|
|
63926
63969
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
63927
|
-
|
|
63970
|
+
continue;
|
|
63928
63971
|
}
|
|
63929
63972
|
}
|
|
63930
63973
|
result = instantiateType(falseType_1, mapper);
|
|
63931
|
-
|
|
63974
|
+
break;
|
|
63932
63975
|
}
|
|
63933
63976
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
63934
63977
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -63939,10 +63982,10 @@ var ts;
|
|
|
63939
63982
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
63940
63983
|
var trueMapper = combinedMapper || mapper;
|
|
63941
63984
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
63942
|
-
|
|
63985
|
+
continue;
|
|
63943
63986
|
}
|
|
63944
63987
|
result = instantiateType(trueType_1, trueMapper);
|
|
63945
|
-
|
|
63988
|
+
break;
|
|
63946
63989
|
}
|
|
63947
63990
|
}
|
|
63948
63991
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -63954,19 +63997,7 @@ var ts;
|
|
|
63954
63997
|
result.combinedMapper = combinedMapper;
|
|
63955
63998
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
63956
63999
|
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;
|
|
64000
|
+
break;
|
|
63970
64001
|
}
|
|
63971
64002
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
63972
64003
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -66420,7 +66451,7 @@ var ts;
|
|
|
66420
66451
|
return 0 /* Ternary.False */;
|
|
66421
66452
|
}
|
|
66422
66453
|
}
|
|
66423
|
-
var isPerformingCommonPropertyChecks = (relation !== comparableRelation ||
|
|
66454
|
+
var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
|
|
66424
66455
|
!(intersectionState & 2 /* IntersectionState.Target */) &&
|
|
66425
66456
|
source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
|
|
66426
66457
|
target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
|
|
@@ -66448,27 +66479,6 @@ var ts;
|
|
|
66448
66479
|
var result_7 = skipCaching ?
|
|
66449
66480
|
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
66450
66481
|
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
66482
|
if (result_7) {
|
|
66473
66483
|
return result_7;
|
|
66474
66484
|
}
|
|
@@ -66580,7 +66590,7 @@ var ts;
|
|
|
66580
66590
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66581
66591
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66582
66592
|
}
|
|
66583
|
-
var
|
|
66593
|
+
var _loop_20 = function (prop) {
|
|
66584
66594
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66585
66595
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66586
66596
|
if (reportErrors) {
|
|
@@ -66643,9 +66653,9 @@ var ts;
|
|
|
66643
66653
|
};
|
|
66644
66654
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66645
66655
|
var prop = _b[_i];
|
|
66646
|
-
var
|
|
66647
|
-
if (typeof
|
|
66648
|
-
return
|
|
66656
|
+
var state_6 = _loop_20(prop);
|
|
66657
|
+
if (typeof state_6 === "object")
|
|
66658
|
+
return state_6.value;
|
|
66649
66659
|
}
|
|
66650
66660
|
return false;
|
|
66651
66661
|
}
|
|
@@ -66866,8 +66876,7 @@ var ts;
|
|
|
66866
66876
|
if (overflow) {
|
|
66867
66877
|
return 0 /* Ternary.False */;
|
|
66868
66878
|
}
|
|
66869
|
-
var
|
|
66870
|
-
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66879
|
+
var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66871
66880
|
var entry = relation.get(id);
|
|
66872
66881
|
if (entry !== undefined) {
|
|
66873
66882
|
if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
|
|
@@ -66897,7 +66906,7 @@ var ts;
|
|
|
66897
66906
|
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
66898
66907
|
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
66899
66908
|
// were unconstrained.
|
|
66900
|
-
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target,
|
|
66909
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
66901
66910
|
for (var i = 0; i < maybeCount; i++) {
|
|
66902
66911
|
// If source and target are already being compared, consider them related with assumptions
|
|
66903
66912
|
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
@@ -66984,7 +66993,7 @@ var ts;
|
|
|
66984
66993
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66985
66994
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66986
66995
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66987
|
-
if (
|
|
66996
|
+
if (relation !== identityRelation) {
|
|
66988
66997
|
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66989
66998
|
// the constituents. When an intersection type contains instantiable types with union type
|
|
66990
66999
|
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
@@ -66998,10 +67007,33 @@ var ts;
|
|
|
66998
67007
|
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66999
67008
|
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
67000
67009
|
// 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
|
-
|
|
67010
|
+
if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
|
|
67011
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
|
|
67012
|
+
if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
67013
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
67014
|
+
result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
67015
|
+
}
|
|
67016
|
+
}
|
|
67017
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
67018
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
67019
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
67020
|
+
//
|
|
67021
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
67022
|
+
//
|
|
67023
|
+
// declare let wrong: { a: { y: string } };
|
|
67024
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
67025
|
+
//
|
|
67026
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
67027
|
+
// x = y; // Mismatched property in source intersection
|
|
67028
|
+
// }
|
|
67029
|
+
//
|
|
67030
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
67031
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
67032
|
+
if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
|
|
67033
|
+
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 */); }))) {
|
|
67034
|
+
inPropertyCheck = true;
|
|
67035
|
+
result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67036
|
+
inPropertyCheck = false;
|
|
67005
67037
|
}
|
|
67006
67038
|
}
|
|
67007
67039
|
if (result) {
|
|
@@ -67010,9 +67042,6 @@ var ts;
|
|
|
67010
67042
|
return result;
|
|
67011
67043
|
}
|
|
67012
67044
|
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
67045
|
var result;
|
|
67017
67046
|
var originalErrorInfo;
|
|
67018
67047
|
var varianceCheckFailed = false;
|
|
@@ -67636,11 +67665,11 @@ var ts;
|
|
|
67636
67665
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67637
67666
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67638
67667
|
var matchingTypes = [];
|
|
67639
|
-
var
|
|
67668
|
+
var _loop_21 = function (combination) {
|
|
67640
67669
|
var hasMatch = false;
|
|
67641
67670
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67642
67671
|
var type = _d[_c];
|
|
67643
|
-
var
|
|
67672
|
+
var _loop_22 = function (i) {
|
|
67644
67673
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67645
67674
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67646
67675
|
if (!targetProperty)
|
|
@@ -67656,8 +67685,8 @@ var ts;
|
|
|
67656
67685
|
}
|
|
67657
67686
|
};
|
|
67658
67687
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67659
|
-
var
|
|
67660
|
-
switch (
|
|
67688
|
+
var state_8 = _loop_22(i);
|
|
67689
|
+
switch (state_8) {
|
|
67661
67690
|
case "continue-outer": continue outer;
|
|
67662
67691
|
}
|
|
67663
67692
|
}
|
|
@@ -67670,9 +67699,9 @@ var ts;
|
|
|
67670
67699
|
};
|
|
67671
67700
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67672
67701
|
var combination = discriminantCombinations_1[_a];
|
|
67673
|
-
var
|
|
67674
|
-
if (typeof
|
|
67675
|
-
return
|
|
67702
|
+
var state_7 = _loop_21(combination);
|
|
67703
|
+
if (typeof state_7 === "object")
|
|
67704
|
+
return state_7.value;
|
|
67676
67705
|
}
|
|
67677
67706
|
// Compare the remaining non-discriminant properties of each match.
|
|
67678
67707
|
var result = -1 /* Ternary.True */;
|
|
@@ -68377,7 +68406,7 @@ var ts;
|
|
|
68377
68406
|
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
68407
|
links.variances = ts.emptyArray;
|
|
68379
68408
|
var variances = [];
|
|
68380
|
-
var
|
|
68409
|
+
var _loop_23 = function (tp) {
|
|
68381
68410
|
var modifiers = getVarianceModifiers(tp);
|
|
68382
68411
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68383
68412
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68415,7 +68444,7 @@ var ts;
|
|
|
68415
68444
|
};
|
|
68416
68445
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68417
68446
|
var tp = typeParameters_2[_i];
|
|
68418
|
-
|
|
68447
|
+
_loop_23(tp);
|
|
68419
68448
|
}
|
|
68420
68449
|
links.variances = variances;
|
|
68421
68450
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -70373,7 +70402,7 @@ var ts;
|
|
|
70373
70402
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70374
70403
|
// succeed. That would be a pointless and confusing outcome.
|
|
70375
70404
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70376
|
-
var
|
|
70405
|
+
var _loop_24 = function (i) {
|
|
70377
70406
|
var source_1 = matches ? matches[i] : neverType;
|
|
70378
70407
|
var target_3 = types[i];
|
|
70379
70408
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70423,7 +70452,7 @@ var ts;
|
|
|
70423
70452
|
inferFromTypes(source_1, target_3);
|
|
70424
70453
|
};
|
|
70425
70454
|
for (var i = 0; i < types.length; i++) {
|
|
70426
|
-
|
|
70455
|
+
_loop_24(i);
|
|
70427
70456
|
}
|
|
70428
70457
|
}
|
|
70429
70458
|
}
|
|
@@ -70952,7 +70981,7 @@ var ts;
|
|
|
70952
70981
|
function mapTypesByKeyProperty(types, name) {
|
|
70953
70982
|
var map = new ts.Map();
|
|
70954
70983
|
var count = 0;
|
|
70955
|
-
var
|
|
70984
|
+
var _loop_25 = function (type) {
|
|
70956
70985
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70957
70986
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70958
70987
|
if (discriminant) {
|
|
@@ -70978,9 +71007,9 @@ var ts;
|
|
|
70978
71007
|
};
|
|
70979
71008
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70980
71009
|
var type = types_15[_i];
|
|
70981
|
-
var
|
|
70982
|
-
if (typeof
|
|
70983
|
-
return
|
|
71010
|
+
var state_9 = _loop_25(type);
|
|
71011
|
+
if (typeof state_9 === "object")
|
|
71012
|
+
return state_9.value;
|
|
70984
71013
|
}
|
|
70985
71014
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70986
71015
|
}
|
|
@@ -77436,7 +77465,7 @@ var ts;
|
|
|
77436
77465
|
if (spreadIndex >= 0) {
|
|
77437
77466
|
// Create synthetic arguments from spreads of tuple types.
|
|
77438
77467
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77439
|
-
var
|
|
77468
|
+
var _loop_26 = function (i) {
|
|
77440
77469
|
var arg = args[i];
|
|
77441
77470
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77442
77471
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77453,7 +77482,7 @@ var ts;
|
|
|
77453
77482
|
}
|
|
77454
77483
|
};
|
|
77455
77484
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77456
|
-
|
|
77485
|
+
_loop_26(i);
|
|
77457
77486
|
}
|
|
77458
77487
|
return effectiveArgs_1;
|
|
77459
77488
|
}
|
|
@@ -77782,7 +77811,7 @@ var ts;
|
|
|
77782
77811
|
var min_3 = Number.MAX_VALUE;
|
|
77783
77812
|
var minIndex = 0;
|
|
77784
77813
|
var i_1 = 0;
|
|
77785
|
-
var
|
|
77814
|
+
var _loop_27 = function (c) {
|
|
77786
77815
|
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
77816
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77788
77817
|
if (diags_2) {
|
|
@@ -77800,7 +77829,7 @@ var ts;
|
|
|
77800
77829
|
};
|
|
77801
77830
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77802
77831
|
var c = candidatesForArgumentError_1[_a];
|
|
77803
|
-
|
|
77832
|
+
_loop_27(c);
|
|
77804
77833
|
}
|
|
77805
77834
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77806
77835
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77958,7 +77987,7 @@ var ts;
|
|
|
77958
77987
|
}
|
|
77959
77988
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77960
77989
|
var parameters = [];
|
|
77961
|
-
var
|
|
77990
|
+
var _loop_28 = function (i) {
|
|
77962
77991
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77963
77992
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77964
77993
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77966,7 +77995,7 @@ var ts;
|
|
|
77966
77995
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77967
77996
|
};
|
|
77968
77997
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77969
|
-
|
|
77998
|
+
_loop_28(i);
|
|
77970
77999
|
}
|
|
77971
78000
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77972
78001
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -82024,7 +82053,7 @@ var ts;
|
|
|
82024
82053
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
82025
82054
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
82026
82055
|
var indexSignatureMap_1 = new ts.Map();
|
|
82027
|
-
var
|
|
82056
|
+
var _loop_29 = function (declaration) {
|
|
82028
82057
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
82029
82058
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
82030
82059
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -82039,7 +82068,7 @@ var ts;
|
|
|
82039
82068
|
};
|
|
82040
82069
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
82041
82070
|
var declaration = _a[_i];
|
|
82042
|
-
|
|
82071
|
+
_loop_29(declaration);
|
|
82043
82072
|
}
|
|
82044
82073
|
indexSignatureMap_1.forEach(function (entry) {
|
|
82045
82074
|
if (entry.declarations.length > 1) {
|
|
@@ -82316,7 +82345,7 @@ var ts;
|
|
|
82316
82345
|
}
|
|
82317
82346
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
82318
82347
|
if (symbol) {
|
|
82319
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82348
|
+
if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82320
82349
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
82321
82350
|
}
|
|
82322
82351
|
if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
|
|
@@ -83694,7 +83723,7 @@ var ts;
|
|
|
83694
83723
|
}
|
|
83695
83724
|
function errorUnusedLocal(declaration, name, addDiagnostic) {
|
|
83696
83725
|
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;
|
|
83726
|
+
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
83727
|
addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
|
|
83699
83728
|
}
|
|
83700
83729
|
function isIdentifierThatStartsWithUnderscore(node) {
|
|
@@ -85648,7 +85677,7 @@ var ts;
|
|
|
85648
85677
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85649
85678
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85650
85679
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85651
|
-
var
|
|
85680
|
+
var _loop_30 = function (info) {
|
|
85652
85681
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85653
85682
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85654
85683
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85665,7 +85694,7 @@ var ts;
|
|
|
85665
85694
|
};
|
|
85666
85695
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85667
85696
|
var info = indexInfos_9[_i];
|
|
85668
|
-
|
|
85697
|
+
_loop_30(info);
|
|
85669
85698
|
}
|
|
85670
85699
|
}
|
|
85671
85700
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85673,7 +85702,7 @@ var ts;
|
|
|
85673
85702
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85674
85703
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85675
85704
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85676
|
-
var
|
|
85705
|
+
var _loop_31 = function (info) {
|
|
85677
85706
|
if (info === checkInfo)
|
|
85678
85707
|
return "continue";
|
|
85679
85708
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85688,7 +85717,7 @@ var ts;
|
|
|
85688
85717
|
};
|
|
85689
85718
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85690
85719
|
var info = indexInfos_10[_i];
|
|
85691
|
-
|
|
85720
|
+
_loop_31(info);
|
|
85692
85721
|
}
|
|
85693
85722
|
}
|
|
85694
85723
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85743,7 +85772,7 @@ var ts;
|
|
|
85743
85772
|
}
|
|
85744
85773
|
else {
|
|
85745
85774
|
ts.forEach(jsdocParameters, function (_a, index) {
|
|
85746
|
-
var name = _a.name;
|
|
85775
|
+
var name = _a.name, isNameFirst = _a.isNameFirst;
|
|
85747
85776
|
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
85748
85777
|
return;
|
|
85749
85778
|
}
|
|
@@ -85753,7 +85782,9 @@ var ts;
|
|
|
85753
85782
|
}
|
|
85754
85783
|
}
|
|
85755
85784
|
else {
|
|
85756
|
-
|
|
85785
|
+
if (!isNameFirst) {
|
|
85786
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
85787
|
+
}
|
|
85757
85788
|
}
|
|
85758
85789
|
});
|
|
85759
85790
|
}
|
|
@@ -86008,7 +86039,7 @@ var ts;
|
|
|
86008
86039
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
86009
86040
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
86010
86041
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
86011
|
-
var
|
|
86042
|
+
var _loop_32 = function (member) {
|
|
86012
86043
|
if (ts.hasAmbientModifier(member)) {
|
|
86013
86044
|
return "continue";
|
|
86014
86045
|
}
|
|
@@ -86025,7 +86056,7 @@ var ts;
|
|
|
86025
86056
|
};
|
|
86026
86057
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86027
86058
|
var member = _a[_i];
|
|
86028
|
-
|
|
86059
|
+
_loop_32(member);
|
|
86029
86060
|
}
|
|
86030
86061
|
}
|
|
86031
86062
|
/**
|
|
@@ -86113,7 +86144,7 @@ var ts;
|
|
|
86113
86144
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
86114
86145
|
// 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
86146
|
var issuedMemberError = false;
|
|
86116
|
-
var
|
|
86147
|
+
var _loop_33 = function (member) {
|
|
86117
86148
|
if (ts.isStatic(member)) {
|
|
86118
86149
|
return "continue";
|
|
86119
86150
|
}
|
|
@@ -86132,7 +86163,7 @@ var ts;
|
|
|
86132
86163
|
};
|
|
86133
86164
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86134
86165
|
var member = _a[_i];
|
|
86135
|
-
|
|
86166
|
+
_loop_33(member);
|
|
86136
86167
|
}
|
|
86137
86168
|
if (!issuedMemberError) {
|
|
86138
86169
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -86203,7 +86234,7 @@ var ts;
|
|
|
86203
86234
|
var _a, _b, _c, _d;
|
|
86204
86235
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
86205
86236
|
var baseProperties = getPropertiesOfType(baseType);
|
|
86206
|
-
var
|
|
86237
|
+
var _loop_34 = function (baseProperty) {
|
|
86207
86238
|
var base = getTargetSymbol(baseProperty);
|
|
86208
86239
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
86209
86240
|
return "continue";
|
|
@@ -86313,8 +86344,8 @@ var ts;
|
|
|
86313
86344
|
};
|
|
86314
86345
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86315
86346
|
var baseProperty = baseProperties_1[_i];
|
|
86316
|
-
var
|
|
86317
|
-
switch (
|
|
86347
|
+
var state_10 = _loop_34(baseProperty);
|
|
86348
|
+
switch (state_10) {
|
|
86318
86349
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86319
86350
|
}
|
|
86320
86351
|
}
|
|
@@ -88024,29 +88055,9 @@ var ts;
|
|
|
88024
88055
|
}
|
|
88025
88056
|
function isTypeDeclarationName(name) {
|
|
88026
88057
|
return name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
88027
|
-
isTypeDeclaration(name.parent) &&
|
|
88058
|
+
ts.isTypeDeclaration(name.parent) &&
|
|
88028
88059
|
ts.getNameOfDeclaration(name.parent) === name;
|
|
88029
88060
|
}
|
|
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
88061
|
// True if the given identifier is part of a type reference
|
|
88051
88062
|
function isTypeReferenceIdentifier(node) {
|
|
88052
88063
|
while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
|
|
@@ -88479,7 +88490,7 @@ var ts;
|
|
|
88479
88490
|
var baseType = ts.firstOrUndefined(getBaseTypes(classType));
|
|
88480
88491
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
|
88481
88492
|
}
|
|
88482
|
-
if (isTypeDeclaration(node)) {
|
|
88493
|
+
if (ts.isTypeDeclaration(node)) {
|
|
88483
88494
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
88484
88495
|
var symbol = getSymbolOfNode(node);
|
|
88485
88496
|
return getDeclaredTypeOfSymbol(symbol);
|
|
@@ -125165,7 +125176,7 @@ var ts;
|
|
|
125165
125176
|
});
|
|
125166
125177
|
// Sort by paths closest to importing file Name directory
|
|
125167
125178
|
var sortedPaths = [];
|
|
125168
|
-
var
|
|
125179
|
+
var _loop_35 = function (directory) {
|
|
125169
125180
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
125170
125181
|
var pathsInDirectory;
|
|
125171
125182
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -125189,9 +125200,9 @@ var ts;
|
|
|
125189
125200
|
};
|
|
125190
125201
|
var out_directory_1;
|
|
125191
125202
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
125192
|
-
var
|
|
125203
|
+
var state_11 = _loop_35(directory);
|
|
125193
125204
|
directory = out_directory_1;
|
|
125194
|
-
if (
|
|
125205
|
+
if (state_11 === "break")
|
|
125195
125206
|
break;
|
|
125196
125207
|
}
|
|
125197
125208
|
if (allFileNames.size) {
|
|
@@ -125260,7 +125271,7 @@ var ts;
|
|
|
125260
125271
|
}
|
|
125261
125272
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125262
125273
|
for (var key in paths) {
|
|
125263
|
-
var
|
|
125274
|
+
var _loop_36 = function (patternText_1) {
|
|
125264
125275
|
var pattern = ts.normalizePath(patternText_1);
|
|
125265
125276
|
var indexOfStar = pattern.indexOf("*");
|
|
125266
125277
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125327,9 +125338,9 @@ var ts;
|
|
|
125327
125338
|
};
|
|
125328
125339
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125329
125340
|
var patternText_1 = _a[_i];
|
|
125330
|
-
var
|
|
125331
|
-
if (typeof
|
|
125332
|
-
return
|
|
125341
|
+
var state_12 = _loop_36(patternText_1);
|
|
125342
|
+
if (typeof state_12 === "object")
|
|
125343
|
+
return state_12.value;
|
|
125333
125344
|
}
|
|
125334
125345
|
}
|
|
125335
125346
|
function validateEnding(_a) {
|
|
@@ -132440,6 +132451,10 @@ var ts;
|
|
|
132440
132451
|
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
|
|
132441
132452
|
}
|
|
132442
132453
|
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
132454
|
+
function isSourceFileFromLibrary(program, node) {
|
|
132455
|
+
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
132456
|
+
}
|
|
132457
|
+
ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
|
|
132443
132458
|
// #endregion
|
|
132444
132459
|
})(ts || (ts = {}));
|
|
132445
132460
|
/*@internal*/
|
|
@@ -157547,6 +157562,143 @@ var ts;
|
|
|
157547
157562
|
})(ts || (ts = {}));
|
|
157548
157563
|
/* @internal */
|
|
157549
157564
|
var ts;
|
|
157565
|
+
(function (ts) {
|
|
157566
|
+
var codefix;
|
|
157567
|
+
(function (codefix) {
|
|
157568
|
+
var fixId = "fixImportNonExportedMember";
|
|
157569
|
+
var errorCodes = [
|
|
157570
|
+
ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
|
|
157571
|
+
];
|
|
157572
|
+
codefix.registerCodeFix({
|
|
157573
|
+
errorCodes: errorCodes,
|
|
157574
|
+
fixIds: [fixId],
|
|
157575
|
+
getCodeActions: function (context) {
|
|
157576
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
157577
|
+
var info = getInfo(sourceFile, span.start, program);
|
|
157578
|
+
if (info === undefined)
|
|
157579
|
+
return undefined;
|
|
157580
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
|
|
157581
|
+
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)];
|
|
157582
|
+
},
|
|
157583
|
+
getAllCodeActions: function (context) {
|
|
157584
|
+
var program = context.program;
|
|
157585
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
157586
|
+
var exports = new ts.Map();
|
|
157587
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
157588
|
+
var info = getInfo(diag.file, diag.start, program);
|
|
157589
|
+
if (info === undefined)
|
|
157590
|
+
return undefined;
|
|
157591
|
+
var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
|
|
157592
|
+
if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
|
|
157593
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157594
|
+
}
|
|
157595
|
+
else {
|
|
157596
|
+
var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
|
|
157597
|
+
if (exportName.isTypeOnly) {
|
|
157598
|
+
moduleExports.typeOnlyExports.push(exportName);
|
|
157599
|
+
}
|
|
157600
|
+
else {
|
|
157601
|
+
moduleExports.exports.push(exportName);
|
|
157602
|
+
}
|
|
157603
|
+
exports.set(moduleSourceFile, moduleExports);
|
|
157604
|
+
}
|
|
157605
|
+
});
|
|
157606
|
+
exports.forEach(function (moduleExports, moduleSourceFile) {
|
|
157607
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
|
|
157608
|
+
if (exportDeclaration && exportDeclaration.isTypeOnly) {
|
|
157609
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
|
|
157610
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
|
|
157611
|
+
}
|
|
157612
|
+
else {
|
|
157613
|
+
doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
|
|
157614
|
+
}
|
|
157615
|
+
});
|
|
157616
|
+
}));
|
|
157617
|
+
}
|
|
157618
|
+
});
|
|
157619
|
+
function getInfo(sourceFile, pos, program) {
|
|
157620
|
+
var _a;
|
|
157621
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
157622
|
+
if (ts.isIdentifier(token)) {
|
|
157623
|
+
var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
|
|
157624
|
+
if (importDeclaration === undefined)
|
|
157625
|
+
return undefined;
|
|
157626
|
+
var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
|
157627
|
+
if (moduleSpecifier === undefined)
|
|
157628
|
+
return undefined;
|
|
157629
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
|
|
157630
|
+
if (resolvedModule === undefined)
|
|
157631
|
+
return undefined;
|
|
157632
|
+
var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
157633
|
+
if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
|
|
157634
|
+
return undefined;
|
|
157635
|
+
var moduleSymbol = moduleSourceFile.symbol;
|
|
157636
|
+
var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
|
|
157637
|
+
if (locals === undefined)
|
|
157638
|
+
return undefined;
|
|
157639
|
+
var localSymbol = locals.get(token.escapedText);
|
|
157640
|
+
if (localSymbol === undefined)
|
|
157641
|
+
return undefined;
|
|
157642
|
+
var node = getNodeOfSymbol(localSymbol);
|
|
157643
|
+
if (node === undefined)
|
|
157644
|
+
return undefined;
|
|
157645
|
+
var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
|
|
157646
|
+
return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
|
|
157647
|
+
}
|
|
157648
|
+
return undefined;
|
|
157649
|
+
}
|
|
157650
|
+
function doChange(changes, program, _a) {
|
|
157651
|
+
var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
|
|
157652
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
157653
|
+
if (exportDeclaration) {
|
|
157654
|
+
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
157655
|
+
}
|
|
157656
|
+
else if (ts.canHaveExportModifier(node)) {
|
|
157657
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157658
|
+
}
|
|
157659
|
+
else {
|
|
157660
|
+
createExport(changes, program, moduleSourceFile, [exportName]);
|
|
157661
|
+
}
|
|
157662
|
+
}
|
|
157663
|
+
function doChanges(changes, program, sourceFile, moduleExports, node) {
|
|
157664
|
+
if (ts.length(moduleExports)) {
|
|
157665
|
+
if (node) {
|
|
157666
|
+
updateExport(changes, program, sourceFile, node, moduleExports);
|
|
157667
|
+
}
|
|
157668
|
+
else {
|
|
157669
|
+
createExport(changes, program, sourceFile, moduleExports);
|
|
157670
|
+
}
|
|
157671
|
+
}
|
|
157672
|
+
}
|
|
157673
|
+
function tryGetExportDeclaration(sourceFile, isTypeOnly) {
|
|
157674
|
+
var predicate = function (node) {
|
|
157675
|
+
return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
|
|
157676
|
+
};
|
|
157677
|
+
return ts.findLast(sourceFile.statements, predicate);
|
|
157678
|
+
}
|
|
157679
|
+
function updateExport(changes, program, sourceFile, node, names) {
|
|
157680
|
+
var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
|
|
157681
|
+
var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
|
|
157682
|
+
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));
|
|
157683
|
+
}
|
|
157684
|
+
function createExport(changes, program, sourceFile, names) {
|
|
157685
|
+
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
|
|
157686
|
+
}
|
|
157687
|
+
function createExportSpecifiers(names, allowTypeModifier) {
|
|
157688
|
+
return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
|
|
157689
|
+
}
|
|
157690
|
+
function getNodeOfSymbol(symbol) {
|
|
157691
|
+
if (symbol.valueDeclaration === undefined) {
|
|
157692
|
+
return ts.firstOrUndefined(symbol.declarations);
|
|
157693
|
+
}
|
|
157694
|
+
var declaration = symbol.valueDeclaration;
|
|
157695
|
+
var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
|
|
157696
|
+
return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
157697
|
+
}
|
|
157698
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
157699
|
+
})(ts || (ts = {}));
|
|
157700
|
+
/* @internal */
|
|
157701
|
+
var ts;
|
|
157550
157702
|
(function (ts) {
|
|
157551
157703
|
var codefix;
|
|
157552
157704
|
(function (codefix) {
|
|
@@ -158077,7 +158229,7 @@ var ts;
|
|
|
158077
158229
|
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
|
|
158078
158230
|
if (argIndex < 0)
|
|
158079
158231
|
return undefined;
|
|
158080
|
-
var signature =
|
|
158232
|
+
var signature = checker.getResolvedSignature(parent.parent);
|
|
158081
158233
|
if (!(signature && signature.declaration && signature.parameters[argIndex]))
|
|
158082
158234
|
return undefined;
|
|
158083
158235
|
var param = signature.parameters[argIndex].valueDeclaration;
|
|
@@ -158124,13 +158276,13 @@ var ts;
|
|
|
158124
158276
|
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
|
|
158125
158277
|
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
|
|
158126
158278
|
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
|
|
158127
|
-
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158279
|
+
if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158128
158280
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
|
|
158129
158281
|
}
|
|
158130
158282
|
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
|
|
158131
158283
|
if (sourceFile.commonJsModuleIndicator)
|
|
158132
158284
|
return undefined;
|
|
158133
|
-
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158285
|
+
if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158134
158286
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
|
|
158135
158287
|
}
|
|
158136
158288
|
}
|
|
@@ -158140,7 +158292,7 @@ var ts;
|
|
|
158140
158292
|
return undefined;
|
|
158141
158293
|
// Prefer to change the class instead of the interface if they are merged
|
|
158142
158294
|
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
158143
|
-
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158295
|
+
if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158144
158296
|
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
158145
158297
|
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
158146
158298
|
return undefined;
|
|
@@ -158152,14 +158304,11 @@ var ts;
|
|
|
158152
158304
|
return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
158153
158305
|
}
|
|
158154
158306
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
158155
|
-
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158307
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158156
158308
|
return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
|
|
158157
158309
|
}
|
|
158158
158310
|
return undefined;
|
|
158159
158311
|
}
|
|
158160
|
-
function isSourceFileFromLibrary(program, node) {
|
|
158161
|
-
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
158162
|
-
}
|
|
158163
158312
|
function getActionsForMissingMemberDeclaration(context, info) {
|
|
158164
158313
|
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
|
|
158165
158314
|
createActionsForAddMissingMemberInTypeScriptFile(context, info);
|
|
@@ -163585,8 +163734,8 @@ var ts;
|
|
|
163585
163734
|
var i = 0;
|
|
163586
163735
|
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
|
|
163587
163736
|
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
|
|
163588
|
-
var description = functionExtraction.description;
|
|
163589
163737
|
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
163738
|
+
var description = functionExtraction.description;
|
|
163590
163739
|
if (functionExtraction.errors.length === 0) {
|
|
163591
163740
|
// Don't issue refactorings with duplicated names.
|
|
163592
163741
|
// Scopes come back in "innermost first" order, so extractions will
|
|
@@ -163610,15 +163759,15 @@ var ts;
|
|
|
163610
163759
|
}
|
|
163611
163760
|
}
|
|
163612
163761
|
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
163762
|
+
var description = constantExtraction.description;
|
|
163613
163763
|
if (constantExtraction.errors.length === 0) {
|
|
163614
163764
|
// Don't issue refactorings with duplicated names.
|
|
163615
163765
|
// Scopes come back in "innermost first" order, so extractions will
|
|
163616
163766
|
// preferentially go into nearer scopes
|
|
163617
|
-
|
|
163618
|
-
|
|
163619
|
-
usedConstantNames.set(description_1, true);
|
|
163767
|
+
if (!usedConstantNames.has(description)) {
|
|
163768
|
+
usedConstantNames.set(description, true);
|
|
163620
163769
|
constantActions.push({
|
|
163621
|
-
description:
|
|
163770
|
+
description: description,
|
|
163622
163771
|
name: "constant_scope_".concat(i),
|
|
163623
163772
|
kind: extractConstantAction.kind
|
|
163624
163773
|
});
|