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/tsserverlibrary.js
CHANGED
|
@@ -108,7 +108,7 @@ var ts;
|
|
|
108
108
|
// The following is baselined as a literal template type without intervention
|
|
109
109
|
/** The version of the TypeScript compiler release */
|
|
110
110
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
111
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
111
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221015");
|
|
112
112
|
/* @internal */
|
|
113
113
|
var Comparison;
|
|
114
114
|
(function (Comparison) {
|
|
@@ -9603,6 +9603,10 @@ var ts;
|
|
|
9603
9603
|
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"),
|
|
9604
9604
|
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"),
|
|
9605
9605
|
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}'"),
|
|
9606
|
+
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}."),
|
|
9607
|
+
Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
|
|
9608
|
+
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}'."),
|
|
9609
|
+
Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
|
|
9606
9610
|
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}'"),
|
|
9607
9611
|
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."),
|
|
9608
9612
|
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."),
|
|
@@ -9919,6 +9923,8 @@ var ts;
|
|
|
9919
9923
|
Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
|
|
9920
9924
|
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9921
9925
|
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9926
|
+
Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
9927
|
+
Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
9922
9928
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9923
9929
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9924
9930
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -21679,6 +21685,32 @@ var ts;
|
|
|
21679
21685
|
return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21680
21686
|
}
|
|
21681
21687
|
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21688
|
+
function isTypeDeclaration(node) {
|
|
21689
|
+
switch (node.kind) {
|
|
21690
|
+
case 165 /* SyntaxKind.TypeParameter */:
|
|
21691
|
+
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
21692
|
+
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
21693
|
+
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
21694
|
+
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
21695
|
+
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
21696
|
+
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
21697
|
+
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
21698
|
+
return true;
|
|
21699
|
+
case 270 /* SyntaxKind.ImportClause */:
|
|
21700
|
+
return node.isTypeOnly;
|
|
21701
|
+
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
21702
|
+
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
21703
|
+
return node.parent.parent.isTypeOnly;
|
|
21704
|
+
default:
|
|
21705
|
+
return false;
|
|
21706
|
+
}
|
|
21707
|
+
}
|
|
21708
|
+
ts.isTypeDeclaration = isTypeDeclaration;
|
|
21709
|
+
function canHaveExportModifier(node) {
|
|
21710
|
+
return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
|
|
21711
|
+
|| ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
|
|
21712
|
+
}
|
|
21713
|
+
ts.canHaveExportModifier = canHaveExportModifier;
|
|
21682
21714
|
})(ts || (ts = {}));
|
|
21683
21715
|
/* @internal */
|
|
21684
21716
|
var ts;
|
|
@@ -44303,6 +44335,9 @@ var ts;
|
|
|
44303
44335
|
requestContainingDirectory: containingDirectory,
|
|
44304
44336
|
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
44305
44337
|
};
|
|
44338
|
+
if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
|
|
44339
|
+
trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
|
|
44340
|
+
}
|
|
44306
44341
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
44307
44342
|
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);
|
|
44308
44343
|
function tryResolve(extensions) {
|
|
@@ -44892,7 +44927,7 @@ var ts;
|
|
|
44892
44927
|
}
|
|
44893
44928
|
if (mainExport) {
|
|
44894
44929
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
44895
|
-
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
44930
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
|
|
44896
44931
|
}
|
|
44897
44932
|
}
|
|
44898
44933
|
else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
|
|
@@ -44972,7 +45007,7 @@ var ts;
|
|
|
44972
45007
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44973
45008
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
44974
45009
|
var target = lookupTable[moduleName];
|
|
44975
|
-
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
45010
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
|
|
44976
45011
|
}
|
|
44977
45012
|
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
|
|
44978
45013
|
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
@@ -44981,17 +45016,17 @@ var ts;
|
|
|
44981
45016
|
var target = lookupTable[potentialTarget];
|
|
44982
45017
|
var starPos = potentialTarget.indexOf("*");
|
|
44983
45018
|
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
44984
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45019
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44985
45020
|
}
|
|
44986
45021
|
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
44987
45022
|
var target = lookupTable[potentialTarget];
|
|
44988
45023
|
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
44989
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45024
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44990
45025
|
}
|
|
44991
45026
|
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
44992
45027
|
var target = lookupTable[potentialTarget];
|
|
44993
45028
|
var subpath = moduleName.substring(potentialTarget.length);
|
|
44994
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
45029
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
|
|
44995
45030
|
}
|
|
44996
45031
|
}
|
|
44997
45032
|
function matchesPatternWithTrailer(target, name) {
|
|
@@ -45008,7 +45043,7 @@ var ts;
|
|
|
45008
45043
|
*/
|
|
45009
45044
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
45010
45045
|
return loadModuleFromTargetImportOrExport;
|
|
45011
|
-
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
45046
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
|
|
45012
45047
|
if (typeof target === "string") {
|
|
45013
45048
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
45014
45049
|
if (state.traceEnabled) {
|
|
@@ -45019,6 +45054,8 @@ var ts;
|
|
|
45019
45054
|
if (!ts.startsWith(target, "./")) {
|
|
45020
45055
|
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
45021
45056
|
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
45057
|
+
traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
|
|
45058
|
+
traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
|
|
45022
45059
|
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
45023
45060
|
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
45024
45061
|
}
|
|
@@ -45045,6 +45082,9 @@ var ts;
|
|
|
45045
45082
|
}
|
|
45046
45083
|
return toSearchResult(/*value*/ undefined);
|
|
45047
45084
|
}
|
|
45085
|
+
if (state.traceEnabled) {
|
|
45086
|
+
trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
|
|
45087
|
+
}
|
|
45048
45088
|
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
45049
45089
|
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
45050
45090
|
if (inputLink)
|
|
@@ -45054,14 +45094,18 @@ var ts;
|
|
|
45054
45094
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
45055
45095
|
if (!Array.isArray(target)) {
|
|
45056
45096
|
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
45057
|
-
var
|
|
45058
|
-
if (
|
|
45059
|
-
|
|
45060
|
-
var
|
|
45097
|
+
var condition = _a[_i];
|
|
45098
|
+
if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
|
45099
|
+
traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
|
45100
|
+
var subTarget = target[condition];
|
|
45101
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
|
|
45061
45102
|
if (result) {
|
|
45062
45103
|
return result;
|
|
45063
45104
|
}
|
|
45064
45105
|
}
|
|
45106
|
+
else {
|
|
45107
|
+
traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
|
|
45108
|
+
}
|
|
45065
45109
|
}
|
|
45066
45110
|
return undefined;
|
|
45067
45111
|
}
|
|
@@ -45074,7 +45118,7 @@ var ts;
|
|
|
45074
45118
|
}
|
|
45075
45119
|
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
45076
45120
|
var elem = target_2[_b];
|
|
45077
|
-
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
45121
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
|
|
45078
45122
|
if (result) {
|
|
45079
45123
|
return result;
|
|
45080
45124
|
}
|
|
@@ -45490,6 +45534,15 @@ var ts;
|
|
|
45490
45534
|
function toSearchResult(value) {
|
|
45491
45535
|
return value !== undefined ? { value: value } : undefined;
|
|
45492
45536
|
}
|
|
45537
|
+
function traceIfEnabled(state, diagnostic) {
|
|
45538
|
+
var args = [];
|
|
45539
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
45540
|
+
args[_i - 2] = arguments[_i];
|
|
45541
|
+
}
|
|
45542
|
+
if (state.traceEnabled) {
|
|
45543
|
+
trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
|
|
45544
|
+
}
|
|
45545
|
+
}
|
|
45493
45546
|
})(ts || (ts = {}));
|
|
45494
45547
|
/* @internal */
|
|
45495
45548
|
var ts;
|
|
@@ -49081,8 +49134,6 @@ var ts;
|
|
|
49081
49134
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
49082
49135
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
49083
49136
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
49084
|
-
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
49085
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
49086
49137
|
})(IntersectionState || (IntersectionState = {}));
|
|
49087
49138
|
var RecursionFlags;
|
|
49088
49139
|
(function (RecursionFlags) {
|
|
@@ -55424,7 +55475,7 @@ var ts;
|
|
|
55424
55475
|
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
|
|
55425
55476
|
var indices = ts.indicesOf(statements);
|
|
55426
55477
|
var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
|
|
55427
|
-
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
|
|
55478
|
+
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
|
|
55428
55479
|
for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
|
|
55429
55480
|
var index_1 = associatedIndices_1[_i];
|
|
55430
55481
|
statements[index_1] = addExportModifier(statements[index_1]);
|
|
@@ -55458,15 +55509,6 @@ var ts;
|
|
|
55458
55509
|
}
|
|
55459
55510
|
return statements;
|
|
55460
55511
|
}
|
|
55461
|
-
function canHaveExportModifier(node) {
|
|
55462
|
-
return ts.isEnumDeclaration(node) ||
|
|
55463
|
-
ts.isVariableStatement(node) ||
|
|
55464
|
-
ts.isFunctionDeclaration(node) ||
|
|
55465
|
-
ts.isClassDeclaration(node) ||
|
|
55466
|
-
(ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
|
|
55467
|
-
ts.isInterfaceDeclaration(node) ||
|
|
55468
|
-
isTypeDeclaration(node);
|
|
55469
|
-
}
|
|
55470
55512
|
function addExportModifier(node) {
|
|
55471
55513
|
var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
|
|
55472
55514
|
return ts.factory.updateModifiers(node, flags);
|
|
@@ -55713,7 +55755,7 @@ var ts;
|
|
|
55713
55755
|
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
55714
55756
|
if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
|
|
55715
55757
|
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
|
|
55716
|
-
canHaveExportModifier(node)) {
|
|
55758
|
+
ts.canHaveExportModifier(node)) {
|
|
55717
55759
|
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
|
|
55718
55760
|
newModifierFlags |= 1 /* ModifierFlags.Export */;
|
|
55719
55761
|
}
|
|
@@ -63840,18 +63882,23 @@ var ts;
|
|
|
63840
63882
|
var result;
|
|
63841
63883
|
var extraTypes;
|
|
63842
63884
|
var tailCount = 0;
|
|
63843
|
-
|
|
63885
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63886
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63887
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63888
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63889
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63890
|
+
while (true) {
|
|
63844
63891
|
if (tailCount === 1000) {
|
|
63845
63892
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63846
63893
|
result = errorType;
|
|
63847
|
-
|
|
63894
|
+
break;
|
|
63848
63895
|
}
|
|
63849
63896
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
63850
63897
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
63851
63898
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
63852
63899
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
63853
63900
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
63854
|
-
return
|
|
63901
|
+
return wildcardType;
|
|
63855
63902
|
}
|
|
63856
63903
|
var combinedMapper = void 0;
|
|
63857
63904
|
if (root.inferTypeParameters) {
|
|
@@ -63884,11 +63931,7 @@ var ts;
|
|
|
63884
63931
|
}
|
|
63885
63932
|
}
|
|
63886
63933
|
}
|
|
63887
|
-
|
|
63888
|
-
// if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
|
|
63889
|
-
// "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
|
|
63890
|
-
// so in those cases we refain from performing inference and retain the uninfered type parameter
|
|
63891
|
-
if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
|
|
63934
|
+
if (!checkTypeInstantiable) {
|
|
63892
63935
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
63893
63936
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
63894
63937
|
// types rules (i.e. proper contravariance) for inferences.
|
|
@@ -63920,14 +63963,14 @@ var ts;
|
|
|
63920
63963
|
var newRoot = falseType_1.root;
|
|
63921
63964
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
63922
63965
|
root = newRoot;
|
|
63923
|
-
|
|
63966
|
+
continue;
|
|
63924
63967
|
}
|
|
63925
63968
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
63926
|
-
|
|
63969
|
+
continue;
|
|
63927
63970
|
}
|
|
63928
63971
|
}
|
|
63929
63972
|
result = instantiateType(falseType_1, mapper);
|
|
63930
|
-
|
|
63973
|
+
break;
|
|
63931
63974
|
}
|
|
63932
63975
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
63933
63976
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -63938,10 +63981,10 @@ var ts;
|
|
|
63938
63981
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
63939
63982
|
var trueMapper = combinedMapper || mapper;
|
|
63940
63983
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
63941
|
-
|
|
63984
|
+
continue;
|
|
63942
63985
|
}
|
|
63943
63986
|
result = instantiateType(trueType_1, trueMapper);
|
|
63944
|
-
|
|
63987
|
+
break;
|
|
63945
63988
|
}
|
|
63946
63989
|
}
|
|
63947
63990
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -63953,19 +63996,7 @@ var ts;
|
|
|
63953
63996
|
result.combinedMapper = combinedMapper;
|
|
63954
63997
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
63955
63998
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
63956
|
-
|
|
63957
|
-
};
|
|
63958
|
-
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63959
|
-
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63960
|
-
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63961
|
-
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63962
|
-
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63963
|
-
while (true) {
|
|
63964
|
-
var state_6 = _loop_20();
|
|
63965
|
-
if (typeof state_6 === "object")
|
|
63966
|
-
return state_6.value;
|
|
63967
|
-
if (state_6 === "break")
|
|
63968
|
-
break;
|
|
63999
|
+
break;
|
|
63969
64000
|
}
|
|
63970
64001
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
63971
64002
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -66419,7 +66450,7 @@ var ts;
|
|
|
66419
66450
|
return 0 /* Ternary.False */;
|
|
66420
66451
|
}
|
|
66421
66452
|
}
|
|
66422
|
-
var isPerformingCommonPropertyChecks = (relation !== comparableRelation ||
|
|
66453
|
+
var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
|
|
66423
66454
|
!(intersectionState & 2 /* IntersectionState.Target */) &&
|
|
66424
66455
|
source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
|
|
66425
66456
|
target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
|
|
@@ -66447,27 +66478,6 @@ var ts;
|
|
|
66447
66478
|
var result_7 = skipCaching ?
|
|
66448
66479
|
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
66449
66480
|
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
66450
|
-
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66451
|
-
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66452
|
-
// examples that all should be errors, but aren't without this extra property check:
|
|
66453
|
-
//
|
|
66454
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66455
|
-
//
|
|
66456
|
-
// declare let wrong: { a: { y: string } };
|
|
66457
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66458
|
-
//
|
|
66459
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
66460
|
-
// x = y; // Mismatched property in source intersection
|
|
66461
|
-
// }
|
|
66462
|
-
//
|
|
66463
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
66464
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
66465
|
-
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
66466
|
-
isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
|
|
66467
|
-
inPropertyCheck = true;
|
|
66468
|
-
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
|
|
66469
|
-
inPropertyCheck = false;
|
|
66470
|
-
}
|
|
66471
66481
|
if (result_7) {
|
|
66472
66482
|
return result_7;
|
|
66473
66483
|
}
|
|
@@ -66579,7 +66589,7 @@ var ts;
|
|
|
66579
66589
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66580
66590
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66581
66591
|
}
|
|
66582
|
-
var
|
|
66592
|
+
var _loop_20 = function (prop) {
|
|
66583
66593
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66584
66594
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66585
66595
|
if (reportErrors) {
|
|
@@ -66642,9 +66652,9 @@ var ts;
|
|
|
66642
66652
|
};
|
|
66643
66653
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66644
66654
|
var prop = _b[_i];
|
|
66645
|
-
var
|
|
66646
|
-
if (typeof
|
|
66647
|
-
return
|
|
66655
|
+
var state_6 = _loop_20(prop);
|
|
66656
|
+
if (typeof state_6 === "object")
|
|
66657
|
+
return state_6.value;
|
|
66648
66658
|
}
|
|
66649
66659
|
return false;
|
|
66650
66660
|
}
|
|
@@ -66865,8 +66875,7 @@ var ts;
|
|
|
66865
66875
|
if (overflow) {
|
|
66866
66876
|
return 0 /* Ternary.False */;
|
|
66867
66877
|
}
|
|
66868
|
-
var
|
|
66869
|
-
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66878
|
+
var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66870
66879
|
var entry = relation.get(id);
|
|
66871
66880
|
if (entry !== undefined) {
|
|
66872
66881
|
if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
|
|
@@ -66896,7 +66905,7 @@ var ts;
|
|
|
66896
66905
|
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
66897
66906
|
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
66898
66907
|
// were unconstrained.
|
|
66899
|
-
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target,
|
|
66908
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
66900
66909
|
for (var i = 0; i < maybeCount; i++) {
|
|
66901
66910
|
// If source and target are already being compared, consider them related with assumptions
|
|
66902
66911
|
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
@@ -66983,7 +66992,7 @@ var ts;
|
|
|
66983
66992
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66984
66993
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66985
66994
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66986
|
-
if (
|
|
66995
|
+
if (relation !== identityRelation) {
|
|
66987
66996
|
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66988
66997
|
// the constituents. When an intersection type contains instantiable types with union type
|
|
66989
66998
|
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
@@ -66997,10 +67006,33 @@ var ts;
|
|
|
66997
67006
|
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66998
67007
|
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66999
67008
|
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
67000
|
-
|
|
67001
|
-
|
|
67002
|
-
|
|
67003
|
-
|
|
67009
|
+
if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
|
|
67010
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
|
|
67011
|
+
if (constraint && !(constraint.flags & 131072 /* TypeFlags.Never */) && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
67012
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
67013
|
+
result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
67014
|
+
}
|
|
67015
|
+
}
|
|
67016
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
67017
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
67018
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
67019
|
+
//
|
|
67020
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
67021
|
+
//
|
|
67022
|
+
// declare let wrong: { a: { y: string } };
|
|
67023
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
67024
|
+
//
|
|
67025
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
67026
|
+
// x = y; // Mismatched property in source intersection
|
|
67027
|
+
// }
|
|
67028
|
+
//
|
|
67029
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
67030
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
67031
|
+
if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
|
|
67032
|
+
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 */); }))) {
|
|
67033
|
+
inPropertyCheck = true;
|
|
67034
|
+
result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67035
|
+
inPropertyCheck = false;
|
|
67004
67036
|
}
|
|
67005
67037
|
}
|
|
67006
67038
|
if (result) {
|
|
@@ -67009,9 +67041,6 @@ var ts;
|
|
|
67009
67041
|
return result;
|
|
67010
67042
|
}
|
|
67011
67043
|
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
67012
|
-
if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
|
|
67013
|
-
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67014
|
-
}
|
|
67015
67044
|
var result;
|
|
67016
67045
|
var originalErrorInfo;
|
|
67017
67046
|
var varianceCheckFailed = false;
|
|
@@ -67635,11 +67664,11 @@ var ts;
|
|
|
67635
67664
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67636
67665
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67637
67666
|
var matchingTypes = [];
|
|
67638
|
-
var
|
|
67667
|
+
var _loop_21 = function (combination) {
|
|
67639
67668
|
var hasMatch = false;
|
|
67640
67669
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67641
67670
|
var type = _d[_c];
|
|
67642
|
-
var
|
|
67671
|
+
var _loop_22 = function (i) {
|
|
67643
67672
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67644
67673
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67645
67674
|
if (!targetProperty)
|
|
@@ -67655,8 +67684,8 @@ var ts;
|
|
|
67655
67684
|
}
|
|
67656
67685
|
};
|
|
67657
67686
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67658
|
-
var
|
|
67659
|
-
switch (
|
|
67687
|
+
var state_8 = _loop_22(i);
|
|
67688
|
+
switch (state_8) {
|
|
67660
67689
|
case "continue-outer": continue outer;
|
|
67661
67690
|
}
|
|
67662
67691
|
}
|
|
@@ -67669,9 +67698,9 @@ var ts;
|
|
|
67669
67698
|
};
|
|
67670
67699
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67671
67700
|
var combination = discriminantCombinations_1[_a];
|
|
67672
|
-
var
|
|
67673
|
-
if (typeof
|
|
67674
|
-
return
|
|
67701
|
+
var state_7 = _loop_21(combination);
|
|
67702
|
+
if (typeof state_7 === "object")
|
|
67703
|
+
return state_7.value;
|
|
67675
67704
|
}
|
|
67676
67705
|
// Compare the remaining non-discriminant properties of each match.
|
|
67677
67706
|
var result = -1 /* Ternary.True */;
|
|
@@ -68376,7 +68405,7 @@ var ts;
|
|
|
68376
68405
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
68377
68406
|
links.variances = ts.emptyArray;
|
|
68378
68407
|
var variances = [];
|
|
68379
|
-
var
|
|
68408
|
+
var _loop_23 = function (tp) {
|
|
68380
68409
|
var modifiers = getVarianceModifiers(tp);
|
|
68381
68410
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68382
68411
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68414,7 +68443,7 @@ var ts;
|
|
|
68414
68443
|
};
|
|
68415
68444
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68416
68445
|
var tp = typeParameters_2[_i];
|
|
68417
|
-
|
|
68446
|
+
_loop_23(tp);
|
|
68418
68447
|
}
|
|
68419
68448
|
links.variances = variances;
|
|
68420
68449
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -70372,7 +70401,7 @@ var ts;
|
|
|
70372
70401
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70373
70402
|
// succeed. That would be a pointless and confusing outcome.
|
|
70374
70403
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70375
|
-
var
|
|
70404
|
+
var _loop_24 = function (i) {
|
|
70376
70405
|
var source_1 = matches ? matches[i] : neverType;
|
|
70377
70406
|
var target_3 = types[i];
|
|
70378
70407
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70422,7 +70451,7 @@ var ts;
|
|
|
70422
70451
|
inferFromTypes(source_1, target_3);
|
|
70423
70452
|
};
|
|
70424
70453
|
for (var i = 0; i < types.length; i++) {
|
|
70425
|
-
|
|
70454
|
+
_loop_24(i);
|
|
70426
70455
|
}
|
|
70427
70456
|
}
|
|
70428
70457
|
}
|
|
@@ -70951,7 +70980,7 @@ var ts;
|
|
|
70951
70980
|
function mapTypesByKeyProperty(types, name) {
|
|
70952
70981
|
var map = new ts.Map();
|
|
70953
70982
|
var count = 0;
|
|
70954
|
-
var
|
|
70983
|
+
var _loop_25 = function (type) {
|
|
70955
70984
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70956
70985
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70957
70986
|
if (discriminant) {
|
|
@@ -70977,9 +71006,9 @@ var ts;
|
|
|
70977
71006
|
};
|
|
70978
71007
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70979
71008
|
var type = types_15[_i];
|
|
70980
|
-
var
|
|
70981
|
-
if (typeof
|
|
70982
|
-
return
|
|
71009
|
+
var state_9 = _loop_25(type);
|
|
71010
|
+
if (typeof state_9 === "object")
|
|
71011
|
+
return state_9.value;
|
|
70983
71012
|
}
|
|
70984
71013
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70985
71014
|
}
|
|
@@ -77435,7 +77464,7 @@ var ts;
|
|
|
77435
77464
|
if (spreadIndex >= 0) {
|
|
77436
77465
|
// Create synthetic arguments from spreads of tuple types.
|
|
77437
77466
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77438
|
-
var
|
|
77467
|
+
var _loop_26 = function (i) {
|
|
77439
77468
|
var arg = args[i];
|
|
77440
77469
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77441
77470
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77452,7 +77481,7 @@ var ts;
|
|
|
77452
77481
|
}
|
|
77453
77482
|
};
|
|
77454
77483
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77455
|
-
|
|
77484
|
+
_loop_26(i);
|
|
77456
77485
|
}
|
|
77457
77486
|
return effectiveArgs_1;
|
|
77458
77487
|
}
|
|
@@ -77781,7 +77810,7 @@ var ts;
|
|
|
77781
77810
|
var min_3 = Number.MAX_VALUE;
|
|
77782
77811
|
var minIndex = 0;
|
|
77783
77812
|
var i_1 = 0;
|
|
77784
|
-
var
|
|
77813
|
+
var _loop_27 = function (c) {
|
|
77785
77814
|
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
|
77786
77815
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77787
77816
|
if (diags_2) {
|
|
@@ -77799,7 +77828,7 @@ var ts;
|
|
|
77799
77828
|
};
|
|
77800
77829
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77801
77830
|
var c = candidatesForArgumentError_1[_a];
|
|
77802
|
-
|
|
77831
|
+
_loop_27(c);
|
|
77803
77832
|
}
|
|
77804
77833
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77805
77834
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77957,7 +77986,7 @@ var ts;
|
|
|
77957
77986
|
}
|
|
77958
77987
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77959
77988
|
var parameters = [];
|
|
77960
|
-
var
|
|
77989
|
+
var _loop_28 = function (i) {
|
|
77961
77990
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77962
77991
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77963
77992
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77965,7 +77994,7 @@ var ts;
|
|
|
77965
77994
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77966
77995
|
};
|
|
77967
77996
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77968
|
-
|
|
77997
|
+
_loop_28(i);
|
|
77969
77998
|
}
|
|
77970
77999
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77971
78000
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -82023,7 +82052,7 @@ var ts;
|
|
|
82023
82052
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
82024
82053
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
82025
82054
|
var indexSignatureMap_1 = new ts.Map();
|
|
82026
|
-
var
|
|
82055
|
+
var _loop_29 = function (declaration) {
|
|
82027
82056
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
82028
82057
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
82029
82058
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -82038,7 +82067,7 @@ var ts;
|
|
|
82038
82067
|
};
|
|
82039
82068
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
82040
82069
|
var declaration = _a[_i];
|
|
82041
|
-
|
|
82070
|
+
_loop_29(declaration);
|
|
82042
82071
|
}
|
|
82043
82072
|
indexSignatureMap_1.forEach(function (entry) {
|
|
82044
82073
|
if (entry.declarations.length > 1) {
|
|
@@ -82315,7 +82344,7 @@ var ts;
|
|
|
82315
82344
|
}
|
|
82316
82345
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
82317
82346
|
if (symbol) {
|
|
82318
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82347
|
+
if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82319
82348
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
82320
82349
|
}
|
|
82321
82350
|
if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
|
|
@@ -83693,7 +83722,7 @@ var ts;
|
|
|
83693
83722
|
}
|
|
83694
83723
|
function errorUnusedLocal(declaration, name, addDiagnostic) {
|
|
83695
83724
|
var node = ts.getNameOfDeclaration(declaration) || declaration;
|
|
83696
|
-
var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83725
|
+
var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83697
83726
|
addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
|
|
83698
83727
|
}
|
|
83699
83728
|
function isIdentifierThatStartsWithUnderscore(node) {
|
|
@@ -85647,7 +85676,7 @@ var ts;
|
|
|
85647
85676
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85648
85677
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85649
85678
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85650
|
-
var
|
|
85679
|
+
var _loop_30 = function (info) {
|
|
85651
85680
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85652
85681
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85653
85682
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85664,7 +85693,7 @@ var ts;
|
|
|
85664
85693
|
};
|
|
85665
85694
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85666
85695
|
var info = indexInfos_9[_i];
|
|
85667
|
-
|
|
85696
|
+
_loop_30(info);
|
|
85668
85697
|
}
|
|
85669
85698
|
}
|
|
85670
85699
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85672,7 +85701,7 @@ var ts;
|
|
|
85672
85701
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85673
85702
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85674
85703
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85675
|
-
var
|
|
85704
|
+
var _loop_31 = function (info) {
|
|
85676
85705
|
if (info === checkInfo)
|
|
85677
85706
|
return "continue";
|
|
85678
85707
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85687,7 +85716,7 @@ var ts;
|
|
|
85687
85716
|
};
|
|
85688
85717
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85689
85718
|
var info = indexInfos_10[_i];
|
|
85690
|
-
|
|
85719
|
+
_loop_31(info);
|
|
85691
85720
|
}
|
|
85692
85721
|
}
|
|
85693
85722
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85742,7 +85771,7 @@ var ts;
|
|
|
85742
85771
|
}
|
|
85743
85772
|
else {
|
|
85744
85773
|
ts.forEach(jsdocParameters, function (_a, index) {
|
|
85745
|
-
var name = _a.name;
|
|
85774
|
+
var name = _a.name, isNameFirst = _a.isNameFirst;
|
|
85746
85775
|
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
85747
85776
|
return;
|
|
85748
85777
|
}
|
|
@@ -85752,7 +85781,9 @@ var ts;
|
|
|
85752
85781
|
}
|
|
85753
85782
|
}
|
|
85754
85783
|
else {
|
|
85755
|
-
|
|
85784
|
+
if (!isNameFirst) {
|
|
85785
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
85786
|
+
}
|
|
85756
85787
|
}
|
|
85757
85788
|
});
|
|
85758
85789
|
}
|
|
@@ -86007,7 +86038,7 @@ var ts;
|
|
|
86007
86038
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
86008
86039
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
86009
86040
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
86010
|
-
var
|
|
86041
|
+
var _loop_32 = function (member) {
|
|
86011
86042
|
if (ts.hasAmbientModifier(member)) {
|
|
86012
86043
|
return "continue";
|
|
86013
86044
|
}
|
|
@@ -86024,7 +86055,7 @@ var ts;
|
|
|
86024
86055
|
};
|
|
86025
86056
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86026
86057
|
var member = _a[_i];
|
|
86027
|
-
|
|
86058
|
+
_loop_32(member);
|
|
86028
86059
|
}
|
|
86029
86060
|
}
|
|
86030
86061
|
/**
|
|
@@ -86112,7 +86143,7 @@ var ts;
|
|
|
86112
86143
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
86113
86144
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
86114
86145
|
var issuedMemberError = false;
|
|
86115
|
-
var
|
|
86146
|
+
var _loop_33 = function (member) {
|
|
86116
86147
|
if (ts.isStatic(member)) {
|
|
86117
86148
|
return "continue";
|
|
86118
86149
|
}
|
|
@@ -86131,7 +86162,7 @@ var ts;
|
|
|
86131
86162
|
};
|
|
86132
86163
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
86133
86164
|
var member = _a[_i];
|
|
86134
|
-
|
|
86165
|
+
_loop_33(member);
|
|
86135
86166
|
}
|
|
86136
86167
|
if (!issuedMemberError) {
|
|
86137
86168
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -86202,7 +86233,7 @@ var ts;
|
|
|
86202
86233
|
var _a, _b, _c, _d;
|
|
86203
86234
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
86204
86235
|
var baseProperties = getPropertiesOfType(baseType);
|
|
86205
|
-
var
|
|
86236
|
+
var _loop_34 = function (baseProperty) {
|
|
86206
86237
|
var base = getTargetSymbol(baseProperty);
|
|
86207
86238
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
86208
86239
|
return "continue";
|
|
@@ -86312,8 +86343,8 @@ var ts;
|
|
|
86312
86343
|
};
|
|
86313
86344
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86314
86345
|
var baseProperty = baseProperties_1[_i];
|
|
86315
|
-
var
|
|
86316
|
-
switch (
|
|
86346
|
+
var state_10 = _loop_34(baseProperty);
|
|
86347
|
+
switch (state_10) {
|
|
86317
86348
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86318
86349
|
}
|
|
86319
86350
|
}
|
|
@@ -88023,29 +88054,9 @@ var ts;
|
|
|
88023
88054
|
}
|
|
88024
88055
|
function isTypeDeclarationName(name) {
|
|
88025
88056
|
return name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
88026
|
-
isTypeDeclaration(name.parent) &&
|
|
88057
|
+
ts.isTypeDeclaration(name.parent) &&
|
|
88027
88058
|
ts.getNameOfDeclaration(name.parent) === name;
|
|
88028
88059
|
}
|
|
88029
|
-
function isTypeDeclaration(node) {
|
|
88030
|
-
switch (node.kind) {
|
|
88031
|
-
case 165 /* SyntaxKind.TypeParameter */:
|
|
88032
|
-
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
88033
|
-
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
88034
|
-
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
88035
|
-
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
88036
|
-
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
88037
|
-
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
88038
|
-
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
88039
|
-
return true;
|
|
88040
|
-
case 270 /* SyntaxKind.ImportClause */:
|
|
88041
|
-
return node.isTypeOnly;
|
|
88042
|
-
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88043
|
-
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88044
|
-
return node.parent.parent.isTypeOnly;
|
|
88045
|
-
default:
|
|
88046
|
-
return false;
|
|
88047
|
-
}
|
|
88048
|
-
}
|
|
88049
88060
|
// True if the given identifier is part of a type reference
|
|
88050
88061
|
function isTypeReferenceIdentifier(node) {
|
|
88051
88062
|
while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
|
|
@@ -88478,7 +88489,7 @@ var ts;
|
|
|
88478
88489
|
var baseType = ts.firstOrUndefined(getBaseTypes(classType));
|
|
88479
88490
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
|
88480
88491
|
}
|
|
88481
|
-
if (isTypeDeclaration(node)) {
|
|
88492
|
+
if (ts.isTypeDeclaration(node)) {
|
|
88482
88493
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
88483
88494
|
var symbol = getSymbolOfNode(node);
|
|
88484
88495
|
return getDeclaredTypeOfSymbol(symbol);
|
|
@@ -125164,7 +125175,7 @@ var ts;
|
|
|
125164
125175
|
});
|
|
125165
125176
|
// Sort by paths closest to importing file Name directory
|
|
125166
125177
|
var sortedPaths = [];
|
|
125167
|
-
var
|
|
125178
|
+
var _loop_35 = function (directory) {
|
|
125168
125179
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
125169
125180
|
var pathsInDirectory;
|
|
125170
125181
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -125188,9 +125199,9 @@ var ts;
|
|
|
125188
125199
|
};
|
|
125189
125200
|
var out_directory_1;
|
|
125190
125201
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
125191
|
-
var
|
|
125202
|
+
var state_11 = _loop_35(directory);
|
|
125192
125203
|
directory = out_directory_1;
|
|
125193
|
-
if (
|
|
125204
|
+
if (state_11 === "break")
|
|
125194
125205
|
break;
|
|
125195
125206
|
}
|
|
125196
125207
|
if (allFileNames.size) {
|
|
@@ -125259,7 +125270,7 @@ var ts;
|
|
|
125259
125270
|
}
|
|
125260
125271
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125261
125272
|
for (var key in paths) {
|
|
125262
|
-
var
|
|
125273
|
+
var _loop_36 = function (patternText_1) {
|
|
125263
125274
|
var pattern = ts.normalizePath(patternText_1);
|
|
125264
125275
|
var indexOfStar = pattern.indexOf("*");
|
|
125265
125276
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125326,9 +125337,9 @@ var ts;
|
|
|
125326
125337
|
};
|
|
125327
125338
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125328
125339
|
var patternText_1 = _a[_i];
|
|
125329
|
-
var
|
|
125330
|
-
if (typeof
|
|
125331
|
-
return
|
|
125340
|
+
var state_12 = _loop_36(patternText_1);
|
|
125341
|
+
if (typeof state_12 === "object")
|
|
125342
|
+
return state_12.value;
|
|
125332
125343
|
}
|
|
125333
125344
|
}
|
|
125334
125345
|
function validateEnding(_a) {
|
|
@@ -132858,6 +132869,10 @@ var ts;
|
|
|
132858
132869
|
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
|
|
132859
132870
|
}
|
|
132860
132871
|
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
132872
|
+
function isSourceFileFromLibrary(program, node) {
|
|
132873
|
+
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
132874
|
+
}
|
|
132875
|
+
ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
|
|
132861
132876
|
// #endregion
|
|
132862
132877
|
})(ts || (ts = {}));
|
|
132863
132878
|
/*@internal*/
|
|
@@ -157965,6 +157980,143 @@ var ts;
|
|
|
157965
157980
|
})(ts || (ts = {}));
|
|
157966
157981
|
/* @internal */
|
|
157967
157982
|
var ts;
|
|
157983
|
+
(function (ts) {
|
|
157984
|
+
var codefix;
|
|
157985
|
+
(function (codefix) {
|
|
157986
|
+
var fixId = "fixImportNonExportedMember";
|
|
157987
|
+
var errorCodes = [
|
|
157988
|
+
ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
|
|
157989
|
+
];
|
|
157990
|
+
codefix.registerCodeFix({
|
|
157991
|
+
errorCodes: errorCodes,
|
|
157992
|
+
fixIds: [fixId],
|
|
157993
|
+
getCodeActions: function (context) {
|
|
157994
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
157995
|
+
var info = getInfo(sourceFile, span.start, program);
|
|
157996
|
+
if (info === undefined)
|
|
157997
|
+
return undefined;
|
|
157998
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
|
|
157999
|
+
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)];
|
|
158000
|
+
},
|
|
158001
|
+
getAllCodeActions: function (context) {
|
|
158002
|
+
var program = context.program;
|
|
158003
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
158004
|
+
var exports = new ts.Map();
|
|
158005
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
158006
|
+
var info = getInfo(diag.file, diag.start, program);
|
|
158007
|
+
if (info === undefined)
|
|
158008
|
+
return undefined;
|
|
158009
|
+
var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
|
|
158010
|
+
if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
|
|
158011
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
158012
|
+
}
|
|
158013
|
+
else {
|
|
158014
|
+
var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
|
|
158015
|
+
if (exportName.isTypeOnly) {
|
|
158016
|
+
moduleExports.typeOnlyExports.push(exportName);
|
|
158017
|
+
}
|
|
158018
|
+
else {
|
|
158019
|
+
moduleExports.exports.push(exportName);
|
|
158020
|
+
}
|
|
158021
|
+
exports.set(moduleSourceFile, moduleExports);
|
|
158022
|
+
}
|
|
158023
|
+
});
|
|
158024
|
+
exports.forEach(function (moduleExports, moduleSourceFile) {
|
|
158025
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
|
|
158026
|
+
if (exportDeclaration && exportDeclaration.isTypeOnly) {
|
|
158027
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
|
|
158028
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
|
|
158029
|
+
}
|
|
158030
|
+
else {
|
|
158031
|
+
doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
|
|
158032
|
+
}
|
|
158033
|
+
});
|
|
158034
|
+
}));
|
|
158035
|
+
}
|
|
158036
|
+
});
|
|
158037
|
+
function getInfo(sourceFile, pos, program) {
|
|
158038
|
+
var _a;
|
|
158039
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
158040
|
+
if (ts.isIdentifier(token)) {
|
|
158041
|
+
var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
|
|
158042
|
+
if (importDeclaration === undefined)
|
|
158043
|
+
return undefined;
|
|
158044
|
+
var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
|
158045
|
+
if (moduleSpecifier === undefined)
|
|
158046
|
+
return undefined;
|
|
158047
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
|
|
158048
|
+
if (resolvedModule === undefined)
|
|
158049
|
+
return undefined;
|
|
158050
|
+
var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
158051
|
+
if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
|
|
158052
|
+
return undefined;
|
|
158053
|
+
var moduleSymbol = moduleSourceFile.symbol;
|
|
158054
|
+
var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
|
|
158055
|
+
if (locals === undefined)
|
|
158056
|
+
return undefined;
|
|
158057
|
+
var localSymbol = locals.get(token.escapedText);
|
|
158058
|
+
if (localSymbol === undefined)
|
|
158059
|
+
return undefined;
|
|
158060
|
+
var node = getNodeOfSymbol(localSymbol);
|
|
158061
|
+
if (node === undefined)
|
|
158062
|
+
return undefined;
|
|
158063
|
+
var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
|
|
158064
|
+
return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
|
|
158065
|
+
}
|
|
158066
|
+
return undefined;
|
|
158067
|
+
}
|
|
158068
|
+
function doChange(changes, program, _a) {
|
|
158069
|
+
var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
|
|
158070
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
158071
|
+
if (exportDeclaration) {
|
|
158072
|
+
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
158073
|
+
}
|
|
158074
|
+
else if (ts.canHaveExportModifier(node)) {
|
|
158075
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
158076
|
+
}
|
|
158077
|
+
else {
|
|
158078
|
+
createExport(changes, program, moduleSourceFile, [exportName]);
|
|
158079
|
+
}
|
|
158080
|
+
}
|
|
158081
|
+
function doChanges(changes, program, sourceFile, moduleExports, node) {
|
|
158082
|
+
if (ts.length(moduleExports)) {
|
|
158083
|
+
if (node) {
|
|
158084
|
+
updateExport(changes, program, sourceFile, node, moduleExports);
|
|
158085
|
+
}
|
|
158086
|
+
else {
|
|
158087
|
+
createExport(changes, program, sourceFile, moduleExports);
|
|
158088
|
+
}
|
|
158089
|
+
}
|
|
158090
|
+
}
|
|
158091
|
+
function tryGetExportDeclaration(sourceFile, isTypeOnly) {
|
|
158092
|
+
var predicate = function (node) {
|
|
158093
|
+
return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
|
|
158094
|
+
};
|
|
158095
|
+
return ts.findLast(sourceFile.statements, predicate);
|
|
158096
|
+
}
|
|
158097
|
+
function updateExport(changes, program, sourceFile, node, names) {
|
|
158098
|
+
var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
|
|
158099
|
+
var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
|
|
158100
|
+
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));
|
|
158101
|
+
}
|
|
158102
|
+
function createExport(changes, program, sourceFile, names) {
|
|
158103
|
+
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
|
|
158104
|
+
}
|
|
158105
|
+
function createExportSpecifiers(names, allowTypeModifier) {
|
|
158106
|
+
return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
|
|
158107
|
+
}
|
|
158108
|
+
function getNodeOfSymbol(symbol) {
|
|
158109
|
+
if (symbol.valueDeclaration === undefined) {
|
|
158110
|
+
return ts.firstOrUndefined(symbol.declarations);
|
|
158111
|
+
}
|
|
158112
|
+
var declaration = symbol.valueDeclaration;
|
|
158113
|
+
var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
|
|
158114
|
+
return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
158115
|
+
}
|
|
158116
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
158117
|
+
})(ts || (ts = {}));
|
|
158118
|
+
/* @internal */
|
|
158119
|
+
var ts;
|
|
157968
158120
|
(function (ts) {
|
|
157969
158121
|
var codefix;
|
|
157970
158122
|
(function (codefix) {
|
|
@@ -158495,7 +158647,7 @@ var ts;
|
|
|
158495
158647
|
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
|
|
158496
158648
|
if (argIndex < 0)
|
|
158497
158649
|
return undefined;
|
|
158498
|
-
var signature =
|
|
158650
|
+
var signature = checker.getResolvedSignature(parent.parent);
|
|
158499
158651
|
if (!(signature && signature.declaration && signature.parameters[argIndex]))
|
|
158500
158652
|
return undefined;
|
|
158501
158653
|
var param = signature.parameters[argIndex].valueDeclaration;
|
|
@@ -158542,13 +158694,13 @@ var ts;
|
|
|
158542
158694
|
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
|
|
158543
158695
|
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
|
|
158544
158696
|
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
|
|
158545
|
-
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158697
|
+
if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158546
158698
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
|
|
158547
158699
|
}
|
|
158548
158700
|
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
|
|
158549
158701
|
if (sourceFile.commonJsModuleIndicator)
|
|
158550
158702
|
return undefined;
|
|
158551
|
-
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158703
|
+
if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158552
158704
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
|
|
158553
158705
|
}
|
|
158554
158706
|
}
|
|
@@ -158558,7 +158710,7 @@ var ts;
|
|
|
158558
158710
|
return undefined;
|
|
158559
158711
|
// Prefer to change the class instead of the interface if they are merged
|
|
158560
158712
|
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
158561
|
-
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158713
|
+
if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158562
158714
|
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
158563
158715
|
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
158564
158716
|
return undefined;
|
|
@@ -158570,14 +158722,11 @@ var ts;
|
|
|
158570
158722
|
return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
158571
158723
|
}
|
|
158572
158724
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
158573
|
-
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158725
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158574
158726
|
return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
|
|
158575
158727
|
}
|
|
158576
158728
|
return undefined;
|
|
158577
158729
|
}
|
|
158578
|
-
function isSourceFileFromLibrary(program, node) {
|
|
158579
|
-
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
158580
|
-
}
|
|
158581
158730
|
function getActionsForMissingMemberDeclaration(context, info) {
|
|
158582
158731
|
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
|
|
158583
158732
|
createActionsForAddMissingMemberInTypeScriptFile(context, info);
|
|
@@ -164003,8 +164152,8 @@ var ts;
|
|
|
164003
164152
|
var i = 0;
|
|
164004
164153
|
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
|
|
164005
164154
|
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
|
|
164006
|
-
var description = functionExtraction.description;
|
|
164007
164155
|
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
164156
|
+
var description = functionExtraction.description;
|
|
164008
164157
|
if (functionExtraction.errors.length === 0) {
|
|
164009
164158
|
// Don't issue refactorings with duplicated names.
|
|
164010
164159
|
// Scopes come back in "innermost first" order, so extractions will
|
|
@@ -164028,15 +164177,15 @@ var ts;
|
|
|
164028
164177
|
}
|
|
164029
164178
|
}
|
|
164030
164179
|
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
164180
|
+
var description = constantExtraction.description;
|
|
164031
164181
|
if (constantExtraction.errors.length === 0) {
|
|
164032
164182
|
// Don't issue refactorings with duplicated names.
|
|
164033
164183
|
// Scopes come back in "innermost first" order, so extractions will
|
|
164034
164184
|
// preferentially go into nearer scopes
|
|
164035
|
-
|
|
164036
|
-
|
|
164037
|
-
usedConstantNames.set(description_1, true);
|
|
164185
|
+
if (!usedConstantNames.has(description)) {
|
|
164186
|
+
usedConstantNames.set(description, true);
|
|
164038
164187
|
constantActions.push({
|
|
164039
|
-
description:
|
|
164188
|
+
description: description,
|
|
164040
164189
|
name: "constant_scope_".concat(i),
|
|
164041
164190
|
kind: extractConstantAction.kind
|
|
164042
164191
|
});
|