@typescript-deploys/pr-build 5.7.0-pr-56941-53 → 5.7.0-pr-57718-9
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 +292 -421
- package/lib/_typingsInstaller.js +1 -1
- package/lib/cs/diagnosticMessages.generated.json +12 -4
- package/lib/de/diagnosticMessages.generated.json +12 -4
- package/lib/es/diagnosticMessages.generated.json +12 -4
- package/lib/fr/diagnosticMessages.generated.json +12 -4
- package/lib/it/diagnosticMessages.generated.json +12 -4
- package/lib/ja/diagnosticMessages.generated.json +12 -4
- package/lib/ko/diagnosticMessages.generated.json +12 -4
- package/lib/lib.es2024.sharedmemory.d.ts +1 -1
- package/lib/pl/diagnosticMessages.generated.json +12 -4
- package/lib/pt-br/diagnosticMessages.generated.json +12 -4
- package/lib/ru/diagnosticMessages.generated.json +12 -4
- package/lib/tr/diagnosticMessages.generated.json +12 -4
- package/lib/typescript.js +535 -548
- package/lib/zh-cn/diagnosticMessages.generated.json +13 -5
- package/lib/zh-tw/diagnosticMessages.generated.json +12 -4
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -945,6 +945,7 @@ __export(typescript_exports, {
|
|
|
945
945
|
getPositionOfLineAndCharacter: () => getPositionOfLineAndCharacter,
|
|
946
946
|
getPossibleGenericSignatures: () => getPossibleGenericSignatures,
|
|
947
947
|
getPossibleOriginalInputExtensionForExtension: () => getPossibleOriginalInputExtensionForExtension,
|
|
948
|
+
getPossibleOriginalInputPathWithoutChangingExt: () => getPossibleOriginalInputPathWithoutChangingExt,
|
|
948
949
|
getPossibleTypeArgumentsInfo: () => getPossibleTypeArgumentsInfo,
|
|
949
950
|
getPreEmitDiagnostics: () => getPreEmitDiagnostics,
|
|
950
951
|
getPrecedingNonSpaceCharacterPosition: () => getPrecedingNonSpaceCharacterPosition,
|
|
@@ -2277,7 +2278,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2277
2278
|
|
|
2278
2279
|
// src/compiler/corePublic.ts
|
|
2279
2280
|
var versionMajorMinor = "5.7";
|
|
2280
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2281
|
+
var version = `${versionMajorMinor}.0-insiders.20241031`;
|
|
2281
2282
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2282
2283
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2283
2284
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6530,7 +6531,6 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6530
6531
|
ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
|
|
6531
6532
|
ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
|
|
6532
6533
|
ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
|
|
6533
|
-
ObjectFlags3[ObjectFlags3["IsNarrowedType"] = 16777216] = "IsNarrowedType";
|
|
6534
6534
|
ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
6535
6535
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
6536
6536
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
@@ -18874,12 +18874,12 @@ function canHaveFlowNode(node) {
|
|
|
18874
18874
|
case 80 /* Identifier */:
|
|
18875
18875
|
case 110 /* ThisKeyword */:
|
|
18876
18876
|
case 108 /* SuperKeyword */:
|
|
18877
|
-
case 212 /* ElementAccessExpression */:
|
|
18878
|
-
case 211 /* PropertyAccessExpression */:
|
|
18879
|
-
case 218 /* FunctionExpression */:
|
|
18880
18877
|
case 166 /* QualifiedName */:
|
|
18881
18878
|
case 236 /* MetaProperty */:
|
|
18879
|
+
case 212 /* ElementAccessExpression */:
|
|
18880
|
+
case 211 /* PropertyAccessExpression */:
|
|
18882
18881
|
case 208 /* BindingElement */:
|
|
18882
|
+
case 218 /* FunctionExpression */:
|
|
18883
18883
|
case 219 /* ArrowFunction */:
|
|
18884
18884
|
case 174 /* MethodDeclaration */:
|
|
18885
18885
|
case 177 /* GetAccessor */:
|
|
@@ -19885,7 +19885,7 @@ function hasInvalidEscape(template) {
|
|
|
19885
19885
|
}
|
|
19886
19886
|
var doubleQuoteEscapedCharsRegExp = /[\\"\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
19887
19887
|
var singleQuoteEscapedCharsRegExp = /[\\'\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
19888
|
-
var backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
19888
|
+
var backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u0009\u000b-\u001f\u2028\u2029\u0085]/g;
|
|
19889
19889
|
var escapedCharsMap = new Map(Object.entries({
|
|
19890
19890
|
" ": "\\t",
|
|
19891
19891
|
"\v": "\\v",
|
|
@@ -20205,6 +20205,12 @@ function getDeclarationEmitExtensionForPath(path) {
|
|
|
20205
20205
|
function getPossibleOriginalInputExtensionForExtension(path) {
|
|
20206
20206
|
return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.d.json.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
|
|
20207
20207
|
}
|
|
20208
|
+
function getPossibleOriginalInputPathWithoutChangingExt(filePath, ignoreCase, outputDir, getCommonSourceDirectory2) {
|
|
20209
|
+
return outputDir ? resolvePath(
|
|
20210
|
+
getCommonSourceDirectory2(),
|
|
20211
|
+
getRelativePathFromDirectory(outputDir, filePath, ignoreCase)
|
|
20212
|
+
) : filePath;
|
|
20213
|
+
}
|
|
20208
20214
|
function getPathsBasePath(options, host) {
|
|
20209
20215
|
var _a;
|
|
20210
20216
|
if (!options.paths) return void 0;
|
|
@@ -21263,11 +21269,11 @@ function getLastChild(node) {
|
|
|
21263
21269
|
});
|
|
21264
21270
|
return lastChild;
|
|
21265
21271
|
}
|
|
21266
|
-
function addToSeen(seen, key
|
|
21272
|
+
function addToSeen(seen, key) {
|
|
21267
21273
|
if (seen.has(key)) {
|
|
21268
21274
|
return false;
|
|
21269
21275
|
}
|
|
21270
|
-
seen.
|
|
21276
|
+
seen.add(key);
|
|
21271
21277
|
return true;
|
|
21272
21278
|
}
|
|
21273
21279
|
function isObjectTypeDeclaration(node) {
|
|
@@ -30140,13 +30146,23 @@ var importStarHelper = {
|
|
|
30140
30146
|
dependencies: [createBindingHelper, setModuleDefaultHelper],
|
|
30141
30147
|
priority: 2,
|
|
30142
30148
|
text: `
|
|
30143
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30144
|
-
|
|
30145
|
-
|
|
30146
|
-
|
|
30147
|
-
|
|
30148
|
-
|
|
30149
|
-
|
|
30149
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30150
|
+
var ownKeys = function(o) {
|
|
30151
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30152
|
+
var ar = [];
|
|
30153
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30154
|
+
return ar;
|
|
30155
|
+
};
|
|
30156
|
+
return ownKeys(o);
|
|
30157
|
+
};
|
|
30158
|
+
return function (mod) {
|
|
30159
|
+
if (mod && mod.__esModule) return mod;
|
|
30160
|
+
var result = {};
|
|
30161
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30162
|
+
__setModuleDefault(result, mod);
|
|
30163
|
+
return result;
|
|
30164
|
+
};
|
|
30165
|
+
})();`
|
|
30150
30166
|
};
|
|
30151
30167
|
var importDefaultHelper = {
|
|
30152
30168
|
name: "typescript:commonjsimportdefault",
|
|
@@ -33784,10 +33800,12 @@ var Parser;
|
|
|
33784
33800
|
case 90 /* DefaultKeyword */:
|
|
33785
33801
|
return nextTokenCanFollowDefaultKeyword();
|
|
33786
33802
|
case 126 /* StaticKeyword */:
|
|
33803
|
+
nextToken();
|
|
33804
|
+
return canFollowModifier();
|
|
33787
33805
|
case 139 /* GetKeyword */:
|
|
33788
33806
|
case 153 /* SetKeyword */:
|
|
33789
33807
|
nextToken();
|
|
33790
|
-
return
|
|
33808
|
+
return canFollowGetOrSetKeyword();
|
|
33791
33809
|
default:
|
|
33792
33810
|
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
33793
33811
|
}
|
|
@@ -33805,6 +33823,9 @@ var Parser;
|
|
|
33805
33823
|
function canFollowModifier() {
|
|
33806
33824
|
return token() === 23 /* OpenBracketToken */ || token() === 19 /* OpenBraceToken */ || token() === 42 /* AsteriskToken */ || token() === 26 /* DotDotDotToken */ || isLiteralPropertyName();
|
|
33807
33825
|
}
|
|
33826
|
+
function canFollowGetOrSetKeyword() {
|
|
33827
|
+
return token() === 23 /* OpenBracketToken */ || isLiteralPropertyName();
|
|
33828
|
+
}
|
|
33808
33829
|
function nextTokenCanFollowDefaultKeyword() {
|
|
33809
33830
|
nextToken();
|
|
33810
33831
|
return token() === 86 /* ClassKeyword */ || token() === 100 /* FunctionKeyword */ || token() === 120 /* InterfaceKeyword */ || token() === 60 /* AtToken */ || token() === 128 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine) || token() === 134 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine);
|
|
@@ -42425,7 +42446,7 @@ function convertToTSConfig(configParseResult, configFileName, host) {
|
|
|
42425
42446
|
const providedKeys = new Set(optionMap.keys());
|
|
42426
42447
|
const impliedCompilerOptions = {};
|
|
42427
42448
|
for (const option in computedOptions) {
|
|
42428
|
-
if (!providedKeys.has(option) &&
|
|
42449
|
+
if (!providedKeys.has(option) && optionDependsOn(option, providedKeys)) {
|
|
42429
42450
|
const implied = computedOptions[option].computeValue(configParseResult.options);
|
|
42430
42451
|
const defaultValue = computedOptions[option].computeValue({});
|
|
42431
42452
|
if (implied !== defaultValue) {
|
|
@@ -42436,6 +42457,17 @@ function convertToTSConfig(configParseResult, configFileName, host) {
|
|
|
42436
42457
|
assign(config.compilerOptions, optionMapToObject(serializeCompilerOptions(impliedCompilerOptions, pathOptions)));
|
|
42437
42458
|
return config;
|
|
42438
42459
|
}
|
|
42460
|
+
function optionDependsOn(option, dependsOn) {
|
|
42461
|
+
const seen = /* @__PURE__ */ new Set();
|
|
42462
|
+
return optionDependsOnRecursive(option);
|
|
42463
|
+
function optionDependsOnRecursive(option2) {
|
|
42464
|
+
var _a;
|
|
42465
|
+
if (addToSeen(seen, option2)) {
|
|
42466
|
+
return some((_a = computedOptions[option2]) == null ? void 0 : _a.dependencies, (dep) => dependsOn.has(dep) || optionDependsOnRecursive(dep));
|
|
42467
|
+
}
|
|
42468
|
+
return false;
|
|
42469
|
+
}
|
|
42470
|
+
}
|
|
42439
42471
|
function optionMapToObject(optionMap) {
|
|
42440
42472
|
return Object.fromEntries(optionMap);
|
|
42441
42473
|
}
|
|
@@ -44844,25 +44876,28 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
44844
44876
|
return toSearchResult({ resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
|
|
44845
44877
|
}
|
|
44846
44878
|
if (!isExternalModuleNameRelative(moduleName)) {
|
|
44847
|
-
let resolved2;
|
|
44848
44879
|
if (features & 2 /* Imports */ && startsWith(moduleName, "#")) {
|
|
44849
|
-
|
|
44850
|
-
|
|
44851
|
-
|
|
44852
|
-
|
|
44880
|
+
const resolved3 = loadModuleFromImports(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
44881
|
+
if (resolved3) {
|
|
44882
|
+
return resolved3.value && { value: { resolved: resolved3.value, isExternalLibraryImport: false } };
|
|
44883
|
+
}
|
|
44853
44884
|
}
|
|
44854
|
-
if (
|
|
44855
|
-
|
|
44856
|
-
|
|
44857
|
-
|
|
44858
|
-
}
|
|
44859
|
-
return void 0;
|
|
44885
|
+
if (features & 4 /* SelfName */) {
|
|
44886
|
+
const resolved3 = loadModuleFromSelfNameReference(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
44887
|
+
if (resolved3) {
|
|
44888
|
+
return resolved3.value && { value: { resolved: resolved3.value, isExternalLibraryImport: false } };
|
|
44860
44889
|
}
|
|
44890
|
+
}
|
|
44891
|
+
if (moduleName.includes(":")) {
|
|
44861
44892
|
if (traceEnabled) {
|
|
44862
|
-
trace(host, Diagnostics.
|
|
44893
|
+
trace(host, Diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1, moduleName, formatExtensions(extensions2));
|
|
44863
44894
|
}
|
|
44864
|
-
|
|
44895
|
+
return void 0;
|
|
44865
44896
|
}
|
|
44897
|
+
if (traceEnabled) {
|
|
44898
|
+
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1, moduleName, formatExtensions(extensions2));
|
|
44899
|
+
}
|
|
44900
|
+
let resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
44866
44901
|
if (extensions2 & 4 /* Declaration */) {
|
|
44867
44902
|
resolved2 ?? (resolved2 = resolveFromTypeRoot(moduleName, state2));
|
|
44868
44903
|
}
|
|
@@ -45405,7 +45440,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
45405
45440
|
mainExport = scope.contents.packageJsonContent.exports["."];
|
|
45406
45441
|
}
|
|
45407
45442
|
if (mainExport) {
|
|
45408
|
-
const
|
|
45443
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(
|
|
45409
45444
|
extensions,
|
|
45410
45445
|
state,
|
|
45411
45446
|
cache,
|
|
@@ -45415,7 +45450,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
45415
45450
|
/*isImports*/
|
|
45416
45451
|
false
|
|
45417
45452
|
);
|
|
45418
|
-
return
|
|
45453
|
+
return loadModuleFromTargetExportOrImport(
|
|
45419
45454
|
mainExport,
|
|
45420
45455
|
"",
|
|
45421
45456
|
/*pattern*/
|
|
@@ -45433,7 +45468,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
45433
45468
|
void 0
|
|
45434
45469
|
);
|
|
45435
45470
|
}
|
|
45436
|
-
const result =
|
|
45471
|
+
const result = loadModuleFromExportsOrImports(
|
|
45437
45472
|
extensions,
|
|
45438
45473
|
state,
|
|
45439
45474
|
cache,
|
|
@@ -45487,7 +45522,7 @@ function loadModuleFromImports(extensions, moduleName, directory, state, cache,
|
|
|
45487
45522
|
void 0
|
|
45488
45523
|
);
|
|
45489
45524
|
}
|
|
45490
|
-
const result =
|
|
45525
|
+
const result = loadModuleFromExportsOrImports(
|
|
45491
45526
|
extensions,
|
|
45492
45527
|
state,
|
|
45493
45528
|
cache,
|
|
@@ -45522,11 +45557,11 @@ function comparePatternKeys(a, b) {
|
|
|
45522
45557
|
if (b.length > a.length) return 1 /* GreaterThan */;
|
|
45523
45558
|
return 0 /* EqualTo */;
|
|
45524
45559
|
}
|
|
45525
|
-
function
|
|
45526
|
-
const
|
|
45560
|
+
function loadModuleFromExportsOrImports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
45561
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
45527
45562
|
if (!endsWith(moduleName, directorySeparator) && !moduleName.includes("*") && hasProperty(lookupTable, moduleName)) {
|
|
45528
45563
|
const target = lookupTable[moduleName];
|
|
45529
|
-
return
|
|
45564
|
+
return loadModuleFromTargetExportOrImport(
|
|
45530
45565
|
target,
|
|
45531
45566
|
/*subpath*/
|
|
45532
45567
|
"",
|
|
@@ -45541,7 +45576,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
45541
45576
|
const target = lookupTable[potentialTarget];
|
|
45542
45577
|
const starPos = potentialTarget.indexOf("*");
|
|
45543
45578
|
const subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
45544
|
-
return
|
|
45579
|
+
return loadModuleFromTargetExportOrImport(
|
|
45545
45580
|
target,
|
|
45546
45581
|
subpath,
|
|
45547
45582
|
/*pattern*/
|
|
@@ -45551,7 +45586,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
45551
45586
|
} else if (endsWith(potentialTarget, "*") && startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
45552
45587
|
const target = lookupTable[potentialTarget];
|
|
45553
45588
|
const subpath = moduleName.substring(potentialTarget.length - 1);
|
|
45554
|
-
return
|
|
45589
|
+
return loadModuleFromTargetExportOrImport(
|
|
45555
45590
|
target,
|
|
45556
45591
|
subpath,
|
|
45557
45592
|
/*pattern*/
|
|
@@ -45561,7 +45596,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
45561
45596
|
} else if (startsWith(moduleName, potentialTarget)) {
|
|
45562
45597
|
const target = lookupTable[potentialTarget];
|
|
45563
45598
|
const subpath = moduleName.substring(potentialTarget.length);
|
|
45564
|
-
return
|
|
45599
|
+
return loadModuleFromTargetExportOrImport(
|
|
45565
45600
|
target,
|
|
45566
45601
|
subpath,
|
|
45567
45602
|
/*pattern*/
|
|
@@ -45581,9 +45616,9 @@ function hasOneAsterisk(patternKey) {
|
|
|
45581
45616
|
const firstStar = patternKey.indexOf("*");
|
|
45582
45617
|
return firstStar !== -1 && firstStar === patternKey.lastIndexOf("*");
|
|
45583
45618
|
}
|
|
45584
|
-
function
|
|
45585
|
-
return
|
|
45586
|
-
function
|
|
45619
|
+
function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
45620
|
+
return loadModuleFromTargetExportOrImport;
|
|
45621
|
+
function loadModuleFromTargetExportOrImport(target, subpath, pattern, key) {
|
|
45587
45622
|
if (typeof target === "string") {
|
|
45588
45623
|
if (!pattern && subpath.length > 0 && !endsWith(target, "/")) {
|
|
45589
45624
|
if (state.traceEnabled) {
|
|
@@ -45673,7 +45708,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
|
45673
45708
|
if (condition === "default" || state.conditions.includes(condition) || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
|
45674
45709
|
traceIfEnabled(state, Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
|
45675
45710
|
const subTarget = target[condition];
|
|
45676
|
-
const result =
|
|
45711
|
+
const result = loadModuleFromTargetExportOrImport(subTarget, subpath, pattern, key);
|
|
45677
45712
|
if (result) {
|
|
45678
45713
|
traceIfEnabled(state, Diagnostics.Resolved_under_condition_0, condition);
|
|
45679
45714
|
traceIfEnabled(state, Diagnostics.Exiting_conditional_exports);
|
|
@@ -45698,7 +45733,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
|
45698
45733
|
);
|
|
45699
45734
|
}
|
|
45700
45735
|
for (const elem of target) {
|
|
45701
|
-
const result =
|
|
45736
|
+
const result = loadModuleFromTargetExportOrImport(elem, subpath, pattern, key);
|
|
45702
45737
|
if (result) {
|
|
45703
45738
|
return result;
|
|
45704
45739
|
}
|
|
@@ -46376,7 +46411,6 @@ function createBinder() {
|
|
|
46376
46411
|
var preSwitchCaseFlow;
|
|
46377
46412
|
var activeLabelList;
|
|
46378
46413
|
var hasExplicitReturn;
|
|
46379
|
-
var inReturnStatement;
|
|
46380
46414
|
var hasFlowEffects;
|
|
46381
46415
|
var emitFlags;
|
|
46382
46416
|
var inStrictMode;
|
|
@@ -46449,7 +46483,6 @@ function createBinder() {
|
|
|
46449
46483
|
currentExceptionTarget = void 0;
|
|
46450
46484
|
activeLabelList = void 0;
|
|
46451
46485
|
hasExplicitReturn = false;
|
|
46452
|
-
inReturnStatement = false;
|
|
46453
46486
|
hasFlowEffects = false;
|
|
46454
46487
|
inAssignmentPattern = false;
|
|
46455
46488
|
emitFlags = 0 /* None */;
|
|
@@ -47214,10 +47247,7 @@ function createBinder() {
|
|
|
47214
47247
|
currentFlow = finishFlowLabel(postIfLabel);
|
|
47215
47248
|
}
|
|
47216
47249
|
function bindReturnOrThrow(node) {
|
|
47217
|
-
const oldInReturnStatement = inReturnStatement;
|
|
47218
|
-
inReturnStatement = true;
|
|
47219
47250
|
bind(node.expression);
|
|
47220
|
-
inReturnStatement = oldInReturnStatement;
|
|
47221
47251
|
if (node.kind === 253 /* ReturnStatement */) {
|
|
47222
47252
|
hasExplicitReturn = true;
|
|
47223
47253
|
if (currentReturnTarget) {
|
|
@@ -47578,16 +47608,10 @@ function createBinder() {
|
|
|
47578
47608
|
hasFlowEffects = false;
|
|
47579
47609
|
bindCondition(node.condition, trueLabel, falseLabel);
|
|
47580
47610
|
currentFlow = finishFlowLabel(trueLabel);
|
|
47581
|
-
if (inReturnStatement) {
|
|
47582
|
-
node.flowNodeWhenTrue = currentFlow;
|
|
47583
|
-
}
|
|
47584
47611
|
bind(node.questionToken);
|
|
47585
47612
|
bind(node.whenTrue);
|
|
47586
47613
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
47587
47614
|
currentFlow = finishFlowLabel(falseLabel);
|
|
47588
|
-
if (inReturnStatement) {
|
|
47589
|
-
node.flowNodeWhenFalse = currentFlow;
|
|
47590
|
-
}
|
|
47591
47615
|
bind(node.colonToken);
|
|
47592
47616
|
bind(node.whenFalse);
|
|
47593
47617
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
@@ -49605,31 +49629,29 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
|
|
|
49605
49629
|
return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true };
|
|
49606
49630
|
}
|
|
49607
49631
|
}
|
|
49608
|
-
|
|
49609
|
-
|
|
49610
|
-
|
|
49611
|
-
|
|
49612
|
-
|
|
49613
|
-
|
|
49614
|
-
|
|
49615
|
-
|
|
49616
|
-
|
|
49617
|
-
|
|
49618
|
-
|
|
49619
|
-
|
|
49620
|
-
|
|
49621
|
-
|
|
49622
|
-
|
|
49623
|
-
|
|
49624
|
-
|
|
49625
|
-
if (pathContainsNodeModules(local)) {
|
|
49626
|
-
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
49627
|
-
} else {
|
|
49628
|
-
pathsSpecifiers = append(pathsSpecifiers, local);
|
|
49629
|
-
}
|
|
49630
|
-
} else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) {
|
|
49632
|
+
const local = getLocalModuleSpecifier(
|
|
49633
|
+
modulePath.path,
|
|
49634
|
+
info,
|
|
49635
|
+
compilerOptions,
|
|
49636
|
+
host,
|
|
49637
|
+
options.overrideImportMode || importingSourceFile.impliedNodeFormat,
|
|
49638
|
+
preferences,
|
|
49639
|
+
/*pathsOnly*/
|
|
49640
|
+
modulePath.isRedirect || !!specifier
|
|
49641
|
+
);
|
|
49642
|
+
if (!local || forAutoImport && isExcludedByRegex(local, preferences.excludeRegexes)) {
|
|
49643
|
+
continue;
|
|
49644
|
+
}
|
|
49645
|
+
if (modulePath.isRedirect) {
|
|
49646
|
+
redirectPathsSpecifiers = append(redirectPathsSpecifiers, local);
|
|
49647
|
+
} else if (pathIsBareSpecifier(local)) {
|
|
49648
|
+
if (pathContainsNodeModules(local)) {
|
|
49631
49649
|
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
49650
|
+
} else {
|
|
49651
|
+
pathsSpecifiers = append(pathsSpecifiers, local);
|
|
49632
49652
|
}
|
|
49653
|
+
} else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) {
|
|
49654
|
+
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
49633
49655
|
}
|
|
49634
49656
|
}
|
|
49635
49657
|
return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? { kind: "paths", moduleSpecifiers: pathsSpecifiers, computedWithoutCache: true } : (redirectPathsSpecifiers == null ? void 0 : redirectPathsSpecifiers.length) ? { kind: "redirect", moduleSpecifiers: redirectPathsSpecifiers, computedWithoutCache: true } : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true } : { kind: "relative", moduleSpecifiers: relativeSpecifiers ?? emptyArray, computedWithoutCache: true };
|
|
@@ -49675,7 +49697,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
49675
49697
|
importMode,
|
|
49676
49698
|
prefersTsExtension(allowedEndings)
|
|
49677
49699
|
);
|
|
49678
|
-
const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : void 0;
|
|
49700
|
+
const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, baseDirectory, getCanonicalFileName, host, compilerOptions) : void 0;
|
|
49679
49701
|
if (pathsOnly) {
|
|
49680
49702
|
return fromPaths;
|
|
49681
49703
|
}
|
|
@@ -49904,10 +49926,11 @@ function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) {
|
|
|
49904
49926
|
return ambientModuleDeclare.name.text;
|
|
49905
49927
|
}
|
|
49906
49928
|
}
|
|
49907
|
-
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
49929
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, baseDirectory, getCanonicalFileName, host, compilerOptions) {
|
|
49908
49930
|
for (const key in paths) {
|
|
49909
49931
|
for (const patternText2 of paths[key]) {
|
|
49910
|
-
const
|
|
49932
|
+
const normalized = normalizePath(patternText2);
|
|
49933
|
+
const pattern = getRelativePathIfInSameVolume(normalized, baseDirectory, getCanonicalFileName) ?? normalized;
|
|
49911
49934
|
const indexOfStar = pattern.indexOf("*");
|
|
49912
49935
|
const candidates = allowedEndings.map((ending) => ({
|
|
49913
49936
|
ending,
|
|
@@ -50236,6 +50259,8 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
50236
50259
|
subModuleName,
|
|
50237
50260
|
versionPaths.paths,
|
|
50238
50261
|
allowedEndings,
|
|
50262
|
+
packageRootPath,
|
|
50263
|
+
getCanonicalFileName,
|
|
50239
50264
|
host,
|
|
50240
50265
|
options
|
|
50241
50266
|
);
|
|
@@ -50531,7 +50556,7 @@ function createTypeChecker(host) {
|
|
|
50531
50556
|
var scanner2;
|
|
50532
50557
|
var Symbol48 = objectAllocator.getSymbolConstructor();
|
|
50533
50558
|
var Type29 = objectAllocator.getTypeConstructor();
|
|
50534
|
-
var
|
|
50559
|
+
var Signature13 = objectAllocator.getSignatureConstructor();
|
|
50535
50560
|
var typeCount = 0;
|
|
50536
50561
|
var symbolCount = 0;
|
|
50537
50562
|
var totalInstantiationCount = 0;
|
|
@@ -51530,7 +51555,6 @@ function createTypeChecker(host) {
|
|
|
51530
51555
|
[".jsx", ".jsx"],
|
|
51531
51556
|
[".json", ".json"]
|
|
51532
51557
|
];
|
|
51533
|
-
var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
|
|
51534
51558
|
initializeTypeChecker();
|
|
51535
51559
|
return checker;
|
|
51536
51560
|
function isDefinitelyReferenceToGlobalSymbolObject(node) {
|
|
@@ -54894,6 +54918,9 @@ function createTypeChecker(host) {
|
|
|
54894
54918
|
}
|
|
54895
54919
|
}
|
|
54896
54920
|
let annotationType = getTypeFromTypeNodeWithoutContext(existing);
|
|
54921
|
+
if (isErrorType(annotationType)) {
|
|
54922
|
+
return true;
|
|
54923
|
+
}
|
|
54897
54924
|
if (requiresAddingUndefined && annotationType) {
|
|
54898
54925
|
annotationType = getOptionalType(annotationType, !isParameter(node));
|
|
54899
54926
|
}
|
|
@@ -55920,7 +55947,7 @@ function createTypeChecker(host) {
|
|
|
55920
55947
|
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
|
|
55921
55948
|
for (const signature of signatures) {
|
|
55922
55949
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
55923
|
-
typeElements.push(preserveCommentsOn(methodDeclaration));
|
|
55950
|
+
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
55924
55951
|
}
|
|
55925
55952
|
if (signatures.length || !optionalToken) {
|
|
55926
55953
|
return;
|
|
@@ -55955,8 +55982,8 @@ function createTypeChecker(host) {
|
|
|
55955
55982
|
optionalToken,
|
|
55956
55983
|
propertyTypeNode
|
|
55957
55984
|
);
|
|
55958
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
55959
|
-
function preserveCommentsOn(node) {
|
|
55985
|
+
typeElements.push(preserveCommentsOn(propertySignature, propertySymbol.valueDeclaration));
|
|
55986
|
+
function preserveCommentsOn(node, range) {
|
|
55960
55987
|
var _a2;
|
|
55961
55988
|
const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 348 /* JSDocPropertyTag */);
|
|
55962
55989
|
if (jsdocPropertyTag) {
|
|
@@ -55964,8 +55991,8 @@ function createTypeChecker(host) {
|
|
|
55964
55991
|
if (commentText) {
|
|
55965
55992
|
setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
|
|
55966
55993
|
}
|
|
55967
|
-
} else if (
|
|
55968
|
-
setCommentRange2(context, node,
|
|
55994
|
+
} else if (range) {
|
|
55995
|
+
setCommentRange2(context, node, range);
|
|
55969
55996
|
}
|
|
55970
55997
|
return node;
|
|
55971
55998
|
}
|
|
@@ -60077,7 +60104,7 @@ function createTypeChecker(host) {
|
|
|
60077
60104
|
const getter = getDeclarationOfKind(symbol, 177 /* GetAccessor */);
|
|
60078
60105
|
const setter = getDeclarationOfKind(symbol, 178 /* SetAccessor */);
|
|
60079
60106
|
const accessor = tryCast(getDeclarationOfKind(symbol, 172 /* PropertyDeclaration */), isAutoAccessorPropertyDeclaration);
|
|
60080
|
-
let type = getter && isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || getAnnotatedAccessorType(getter) || getAnnotatedAccessorType(setter) || getAnnotatedAccessorType(accessor) || getter && getter.body && getReturnTypeFromBody(getter) || accessor &&
|
|
60107
|
+
let type = getter && isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || getAnnotatedAccessorType(getter) || getAnnotatedAccessorType(setter) || getAnnotatedAccessorType(accessor) || getter && getter.body && getReturnTypeFromBody(getter) || accessor && getWidenedTypeForVariableLikeDeclaration(
|
|
60081
60108
|
accessor,
|
|
60082
60109
|
/*reportErrors*/
|
|
60083
60110
|
true
|
|
@@ -61176,7 +61203,7 @@ function createTypeChecker(host) {
|
|
|
61176
61203
|
resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments);
|
|
61177
61204
|
}
|
|
61178
61205
|
function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) {
|
|
61179
|
-
const sig = new
|
|
61206
|
+
const sig = new Signature13(checker, flags);
|
|
61180
61207
|
sig.declaration = declaration;
|
|
61181
61208
|
sig.typeParameters = typeParameters;
|
|
61182
61209
|
sig.parameters = parameters;
|
|
@@ -63760,14 +63787,11 @@ function createTypeChecker(host) {
|
|
|
63760
63787
|
function isNoInferType(type) {
|
|
63761
63788
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
|
63762
63789
|
}
|
|
63763
|
-
function
|
|
63764
|
-
return
|
|
63790
|
+
function getSubstitutionType(baseType, constraint) {
|
|
63791
|
+
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint);
|
|
63765
63792
|
}
|
|
63766
|
-
function
|
|
63767
|
-
|
|
63768
|
-
}
|
|
63769
|
-
function getOrCreateSubstitutionType(baseType, constraint, isNarrowed) {
|
|
63770
|
-
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}${isNarrowed ? ">N" : ""}`;
|
|
63793
|
+
function getOrCreateSubstitutionType(baseType, constraint) {
|
|
63794
|
+
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
|
|
63771
63795
|
const cached = substitutionTypes.get(id);
|
|
63772
63796
|
if (cached) {
|
|
63773
63797
|
return cached;
|
|
@@ -63775,9 +63799,6 @@ function createTypeChecker(host) {
|
|
|
63775
63799
|
const result = createType(33554432 /* Substitution */);
|
|
63776
63800
|
result.baseType = baseType;
|
|
63777
63801
|
result.constraint = constraint;
|
|
63778
|
-
if (isNarrowed) {
|
|
63779
|
-
result.objectFlags |= 16777216 /* IsNarrowedType */;
|
|
63780
|
-
}
|
|
63781
63802
|
substitutionTypes.set(id, result);
|
|
63782
63803
|
return result;
|
|
63783
63804
|
}
|
|
@@ -65980,7 +66001,7 @@ function createTypeChecker(host) {
|
|
|
65980
66001
|
function isDeferredType(type, checkTuples) {
|
|
65981
66002
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
65982
66003
|
}
|
|
65983
|
-
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments
|
|
66004
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
|
65984
66005
|
let result;
|
|
65985
66006
|
let extraTypes;
|
|
65986
66007
|
let tailCount = 0;
|
|
@@ -65997,11 +66018,10 @@ function createTypeChecker(host) {
|
|
|
65997
66018
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
65998
66019
|
return wildcardType;
|
|
65999
66020
|
}
|
|
66000
|
-
const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
|
|
66001
66021
|
const checkTypeNode = skipTypeParentheses(root.node.checkType);
|
|
66002
66022
|
const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
|
|
66003
66023
|
const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
|
|
66004
|
-
const checkTypeDeferred = isDeferredType(
|
|
66024
|
+
const checkTypeDeferred = isDeferredType(checkType, checkTuples);
|
|
66005
66025
|
let combinedMapper;
|
|
66006
66026
|
if (root.inferTypeParameters) {
|
|
66007
66027
|
const context = createInferenceContext(
|
|
@@ -66020,8 +66040,8 @@ function createTypeChecker(host) {
|
|
|
66020
66040
|
}
|
|
66021
66041
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
66022
66042
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
|
66023
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (
|
|
66024
|
-
if (
|
|
66043
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
66044
|
+
if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
|
|
66025
66045
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
|
66026
66046
|
}
|
|
66027
66047
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
@@ -66038,7 +66058,7 @@ function createTypeChecker(host) {
|
|
|
66038
66058
|
result = instantiateType(falseType2, mapper);
|
|
66039
66059
|
break;
|
|
66040
66060
|
}
|
|
66041
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(
|
|
66061
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
66042
66062
|
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
66043
66063
|
const trueMapper = combinedMapper || mapper;
|
|
66044
66064
|
if (canTailRecurse(trueType2, trueMapper)) {
|
|
@@ -66229,7 +66249,7 @@ function createTypeChecker(host) {
|
|
|
66229
66249
|
const links = getNodeLinks(node);
|
|
66230
66250
|
if (!links.resolvedType) {
|
|
66231
66251
|
const aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
66232
|
-
if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
|
|
66252
|
+
if (!node.symbol || getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
|
|
66233
66253
|
links.resolvedType = emptyTypeLiteralType;
|
|
66234
66254
|
} else {
|
|
66235
66255
|
let type = createObjectType(16 /* Anonymous */, node.symbol);
|
|
@@ -67004,44 +67024,8 @@ function createTypeChecker(host) {
|
|
|
67004
67024
|
if (!result) {
|
|
67005
67025
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
67006
67026
|
const checkType = root.checkType;
|
|
67007
|
-
|
|
67008
|
-
|
|
67009
|
-
const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(type, mapper);
|
|
67010
|
-
if (forNarrowing) {
|
|
67011
|
-
narrowingBaseType = distributionType.baseType;
|
|
67012
|
-
distributionType = getReducedType(distributionType.constraint);
|
|
67013
|
-
}
|
|
67014
|
-
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
67015
|
-
const mapperCallback = narrowingBaseType ? (t) => getConditionalType(
|
|
67016
|
-
root,
|
|
67017
|
-
prependTypeMapping(checkType, getSubstitutionType(
|
|
67018
|
-
narrowingBaseType,
|
|
67019
|
-
t,
|
|
67020
|
-
/*isNarrowed*/
|
|
67021
|
-
true
|
|
67022
|
-
), newMapper),
|
|
67023
|
-
forConstraint,
|
|
67024
|
-
/*aliasSymbol*/
|
|
67025
|
-
void 0,
|
|
67026
|
-
/*aliasTypeArguments*/
|
|
67027
|
-
void 0,
|
|
67028
|
-
forNarrowing
|
|
67029
|
-
) : (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint);
|
|
67030
|
-
if (narrowingBaseType) {
|
|
67031
|
-
result = mapType(
|
|
67032
|
-
distributionType,
|
|
67033
|
-
mapperCallback,
|
|
67034
|
-
/*noReductions*/
|
|
67035
|
-
void 0,
|
|
67036
|
-
/*toIntersection*/
|
|
67037
|
-
true
|
|
67038
|
-
);
|
|
67039
|
-
} else {
|
|
67040
|
-
result = mapTypeWithAlias(distributionType, mapperCallback, aliasSymbol, aliasTypeArguments);
|
|
67041
|
-
}
|
|
67042
|
-
} else {
|
|
67043
|
-
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
|
67044
|
-
}
|
|
67027
|
+
const distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
|
|
67028
|
+
result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
|
|
67045
67029
|
root.instantiations.set(id, result);
|
|
67046
67030
|
}
|
|
67047
67031
|
return result;
|
|
@@ -67154,9 +67138,6 @@ function createTypeChecker(host) {
|
|
|
67154
67138
|
}
|
|
67155
67139
|
return type;
|
|
67156
67140
|
}
|
|
67157
|
-
function isGenericIndexedOrConditionalReturnType(type) {
|
|
67158
|
-
return !!(type.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */) && couldContainTypeVariables(type));
|
|
67159
|
-
}
|
|
67160
67141
|
function instantiateReverseMappedType(type, mapper) {
|
|
67161
67142
|
const innerMappedType = instantiateType(type.mappedType, mapper);
|
|
67162
67143
|
if (!(getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
|
|
@@ -68187,12 +68168,10 @@ function createTypeChecker(host) {
|
|
|
68187
68168
|
function shouldNormalizeIntersection(type) {
|
|
68188
68169
|
let hasInstantiable = false;
|
|
68189
68170
|
let hasNullableOrEmpty = false;
|
|
68190
|
-
let hasSubstitution = false;
|
|
68191
68171
|
for (const t of type.types) {
|
|
68192
68172
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
68193
68173
|
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
68194
|
-
|
|
68195
|
-
if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
|
|
68174
|
+
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
68196
68175
|
}
|
|
68197
68176
|
return false;
|
|
68198
68177
|
}
|
|
@@ -73327,7 +73306,7 @@ function createTypeChecker(host) {
|
|
|
73327
73306
|
function countTypes(type) {
|
|
73328
73307
|
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
73329
73308
|
}
|
|
73330
|
-
function mapType(type, mapper, noReductions
|
|
73309
|
+
function mapType(type, mapper, noReductions) {
|
|
73331
73310
|
if (type.flags & 131072 /* Never */) {
|
|
73332
73311
|
return type;
|
|
73333
73312
|
}
|
|
@@ -73349,7 +73328,7 @@ function createTypeChecker(host) {
|
|
|
73349
73328
|
}
|
|
73350
73329
|
}
|
|
73351
73330
|
}
|
|
73352
|
-
return changed ? mappedTypes &&
|
|
73331
|
+
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
73353
73332
|
}
|
|
73354
73333
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
73355
73334
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
|
@@ -74702,12 +74681,14 @@ function createTypeChecker(host) {
|
|
|
74702
74681
|
case 80 /* Identifier */:
|
|
74703
74682
|
if (!isMatchingReference(reference, expr) && inlineLevel < 5) {
|
|
74704
74683
|
const symbol = getResolvedSymbol(expr);
|
|
74705
|
-
|
|
74706
|
-
|
|
74707
|
-
|
|
74708
|
-
|
|
74709
|
-
|
|
74710
|
-
|
|
74684
|
+
if (isConstantVariable(symbol)) {
|
|
74685
|
+
const declaration = symbol.valueDeclaration;
|
|
74686
|
+
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isConstantReference(reference)) {
|
|
74687
|
+
inlineLevel++;
|
|
74688
|
+
const result = narrowType(type, declaration.initializer, assumeTrue);
|
|
74689
|
+
inlineLevel--;
|
|
74690
|
+
return result;
|
|
74691
|
+
}
|
|
74711
74692
|
}
|
|
74712
74693
|
}
|
|
74713
74694
|
// falls through
|
|
@@ -74742,14 +74723,6 @@ function createTypeChecker(host) {
|
|
|
74742
74723
|
return type;
|
|
74743
74724
|
}
|
|
74744
74725
|
}
|
|
74745
|
-
function getNarrowableInlineExpression(symbol) {
|
|
74746
|
-
if (isConstantVariable(symbol)) {
|
|
74747
|
-
const declaration = symbol.valueDeclaration;
|
|
74748
|
-
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer) {
|
|
74749
|
-
return declaration.initializer;
|
|
74750
|
-
}
|
|
74751
|
-
}
|
|
74752
|
-
}
|
|
74753
74726
|
function getTypeOfSymbolAtLocation(symbol, location) {
|
|
74754
74727
|
symbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
74755
74728
|
if (location.kind === 80 /* Identifier */ || location.kind === 81 /* PrivateIdentifier */) {
|
|
@@ -74939,11 +74912,11 @@ function createTypeChecker(host) {
|
|
|
74939
74912
|
));
|
|
74940
74913
|
return contextualType && !isGenericType(contextualType);
|
|
74941
74914
|
}
|
|
74942
|
-
function getNarrowableTypeForReference(type, reference, checkMode
|
|
74915
|
+
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
74943
74916
|
if (isNoInferType(type)) {
|
|
74944
74917
|
type = type.baseType;
|
|
74945
74918
|
}
|
|
74946
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (
|
|
74919
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
74947
74920
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
74948
74921
|
}
|
|
74949
74922
|
function isExportOrExportExpression(location) {
|
|
@@ -76068,16 +76041,9 @@ function createTypeChecker(host) {
|
|
|
76068
76041
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
76069
76042
|
const func = getContainingFunction(node);
|
|
76070
76043
|
if (func) {
|
|
76071
|
-
const functionFlags = getFunctionFlags(func);
|
|
76072
|
-
const links = getNodeLinks(node);
|
|
76073
|
-
if (links.contextualReturnType) {
|
|
76074
|
-
if (functionFlags & 2 /* Async */) {
|
|
76075
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
76076
|
-
}
|
|
76077
|
-
return links.contextualReturnType;
|
|
76078
|
-
}
|
|
76079
76044
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
76080
76045
|
if (contextualReturnType) {
|
|
76046
|
+
const functionFlags = getFunctionFlags(func);
|
|
76081
76047
|
if (functionFlags & 1 /* Generator */) {
|
|
76082
76048
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
76083
76049
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -76775,13 +76741,6 @@ function createTypeChecker(host) {
|
|
|
76775
76741
|
if (index >= 0) {
|
|
76776
76742
|
return contextualTypes[index];
|
|
76777
76743
|
}
|
|
76778
|
-
const links = getNodeLinks(node);
|
|
76779
|
-
if (links.contextualReturnType) {
|
|
76780
|
-
if (node.flags & 65536 /* AwaitContext */) {
|
|
76781
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
76782
|
-
}
|
|
76783
|
-
return links.contextualReturnType;
|
|
76784
|
-
}
|
|
76785
76744
|
const { parent: parent2 } = node;
|
|
76786
76745
|
switch (parent2.kind) {
|
|
76787
76746
|
case 260 /* VariableDeclaration */:
|
|
@@ -87221,7 +87180,7 @@ function createTypeChecker(host) {
|
|
|
87221
87180
|
return anyIterationTypes;
|
|
87222
87181
|
}
|
|
87223
87182
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
87224
|
-
const errorOutputContainer = errorNode ? { errors: void 0 } : void 0;
|
|
87183
|
+
const errorOutputContainer = errorNode ? { errors: void 0, skipLogging: true } : void 0;
|
|
87225
87184
|
const iterationTypes2 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
87226
87185
|
if (iterationTypes2 === noIterationTypes) {
|
|
87227
87186
|
if (errorNode) {
|
|
@@ -87389,11 +87348,27 @@ function createTypeChecker(host) {
|
|
|
87389
87348
|
if (isTypeAny(methodType)) {
|
|
87390
87349
|
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
87391
87350
|
}
|
|
87392
|
-
const
|
|
87393
|
-
|
|
87351
|
+
const allSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : void 0;
|
|
87352
|
+
const validSignatures = filter(allSignatures, (sig) => getMinArgumentCount(sig) === 0);
|
|
87353
|
+
if (!some(validSignatures)) {
|
|
87354
|
+
if (errorNode && some(allSignatures)) {
|
|
87355
|
+
checkTypeAssignableTo(
|
|
87356
|
+
type,
|
|
87357
|
+
resolver.getGlobalIterableType(
|
|
87358
|
+
/*reportErrors*/
|
|
87359
|
+
true
|
|
87360
|
+
),
|
|
87361
|
+
errorNode,
|
|
87362
|
+
/*headMessage*/
|
|
87363
|
+
void 0,
|
|
87364
|
+
/*containingMessageChain*/
|
|
87365
|
+
void 0,
|
|
87366
|
+
errorOutputContainer
|
|
87367
|
+
);
|
|
87368
|
+
}
|
|
87394
87369
|
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
87395
87370
|
}
|
|
87396
|
-
const iteratorType = getIntersectionType(map(
|
|
87371
|
+
const iteratorType = getIntersectionType(map(validSignatures, getReturnTypeOfSignature));
|
|
87397
87372
|
const iterationTypes = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache) ?? noIterationTypes;
|
|
87398
87373
|
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
87399
87374
|
}
|
|
@@ -87671,234 +87646,34 @@ function createTypeChecker(host) {
|
|
|
87671
87646
|
}
|
|
87672
87647
|
const signature = getSignatureFromDeclaration(container);
|
|
87673
87648
|
const returnType = getReturnTypeOfSignature(signature);
|
|
87649
|
+
const functionFlags = getFunctionFlags(container);
|
|
87674
87650
|
if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
|
|
87651
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
87675
87652
|
if (container.kind === 178 /* SetAccessor */) {
|
|
87676
87653
|
if (node.expression) {
|
|
87677
87654
|
error2(node, Diagnostics.Setters_cannot_return_a_value);
|
|
87678
87655
|
}
|
|
87679
87656
|
} else if (container.kind === 176 /* Constructor */) {
|
|
87680
|
-
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
87681
87657
|
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
|
|
87682
87658
|
error2(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
87683
87659
|
}
|
|
87684
87660
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
87685
|
-
|
|
87661
|
+
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
87662
|
+
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
87663
|
+
exprType,
|
|
87664
|
+
/*withAlias*/
|
|
87665
|
+
false,
|
|
87666
|
+
node,
|
|
87667
|
+
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
87668
|
+
) : exprType;
|
|
87669
|
+
if (unwrappedReturnType) {
|
|
87670
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
|
|
87671
|
+
}
|
|
87686
87672
|
}
|
|
87687
87673
|
} else if (container.kind !== 176 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
87688
87674
|
error2(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
87689
87675
|
}
|
|
87690
87676
|
}
|
|
87691
|
-
function checkReturnStatementExpression(container, returnType, node, expr) {
|
|
87692
|
-
const functionFlags = getFunctionFlags(container);
|
|
87693
|
-
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
87694
|
-
if (expr) {
|
|
87695
|
-
const unwrappedExpr = skipParentheses(expr);
|
|
87696
|
-
if (isConditionalExpression(unwrappedExpr)) {
|
|
87697
|
-
return checkReturnConditionalExpression(container, returnType, node, unwrappedExpr);
|
|
87698
|
-
}
|
|
87699
|
-
}
|
|
87700
|
-
const exprType = expr ? checkExpressionCached(expr) : undefinedType;
|
|
87701
|
-
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
87702
|
-
exprType,
|
|
87703
|
-
/*withAlias*/
|
|
87704
|
-
false,
|
|
87705
|
-
node,
|
|
87706
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
87707
|
-
) : exprType;
|
|
87708
|
-
const errorNode = node.expression && isConditionalExpression(skipParentheses(node.expression)) ? expr : node;
|
|
87709
|
-
if (checkTypeAssignableTo(
|
|
87710
|
-
unwrappedExprType,
|
|
87711
|
-
unwrappedReturnType,
|
|
87712
|
-
/*errorNode*/
|
|
87713
|
-
void 0
|
|
87714
|
-
)) {
|
|
87715
|
-
return;
|
|
87716
|
-
}
|
|
87717
|
-
if (!isGenericIndexedOrConditionalReturnType(unwrappedReturnType)) {
|
|
87718
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, expr);
|
|
87719
|
-
return;
|
|
87720
|
-
}
|
|
87721
|
-
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
|
87722
|
-
container,
|
|
87723
|
-
/*includeThisTypes*/
|
|
87724
|
-
false
|
|
87725
|
-
), getEffectiveTypeParameterDeclarations(container));
|
|
87726
|
-
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
|
87727
|
-
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
|
87728
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, expr);
|
|
87729
|
-
return;
|
|
87730
|
-
}
|
|
87731
|
-
let narrowPosition = node;
|
|
87732
|
-
let narrowFlowNode = node.flowNode;
|
|
87733
|
-
if (expr && isConditionalExpression(expr.parent)) {
|
|
87734
|
-
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
|
87735
|
-
narrowPosition = expr;
|
|
87736
|
-
}
|
|
87737
|
-
if (!narrowFlowNode) {
|
|
87738
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, expr);
|
|
87739
|
-
return;
|
|
87740
|
-
}
|
|
87741
|
-
const narrowed = mapDefined(narrowableTypeParameters, ([typeParam, symbol, reference]) => {
|
|
87742
|
-
const narrowReference = factory.cloneNode(reference);
|
|
87743
|
-
narrowReference.id = void 0;
|
|
87744
|
-
getNodeLinks(narrowReference).resolvedSymbol = symbol;
|
|
87745
|
-
setParent(narrowReference, narrowPosition.parent);
|
|
87746
|
-
narrowReference.flowNode = narrowFlowNode;
|
|
87747
|
-
const initialType = getNarrowableTypeForReference(
|
|
87748
|
-
typeParam,
|
|
87749
|
-
narrowReference,
|
|
87750
|
-
/*checkMode*/
|
|
87751
|
-
void 0,
|
|
87752
|
-
/*forReturnTypeNarrowing*/
|
|
87753
|
-
true
|
|
87754
|
-
);
|
|
87755
|
-
if (initialType === typeParam) {
|
|
87756
|
-
return void 0;
|
|
87757
|
-
}
|
|
87758
|
-
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
|
87759
|
-
const exprType2 = getTypeFromFlowType(flowType);
|
|
87760
|
-
if (isTypeAny(exprType2) || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
|
87761
|
-
return void 0;
|
|
87762
|
-
}
|
|
87763
|
-
const narrowedType = getSubstitutionType(
|
|
87764
|
-
typeParam,
|
|
87765
|
-
exprType2,
|
|
87766
|
-
/*isNarrowed*/
|
|
87767
|
-
true
|
|
87768
|
-
);
|
|
87769
|
-
return [typeParam, narrowedType];
|
|
87770
|
-
});
|
|
87771
|
-
const narrowMapper = createTypeMapper(narrowed.map(([tp, _]) => tp), narrowed.map(([_, t]) => t));
|
|
87772
|
-
const narrowedReturnType = instantiateType(
|
|
87773
|
-
unwrappedReturnType,
|
|
87774
|
-
narrowMapper
|
|
87775
|
-
);
|
|
87776
|
-
if (expr) {
|
|
87777
|
-
const links = getNodeLinks(expr);
|
|
87778
|
-
if (!links.contextualReturnType) {
|
|
87779
|
-
links.contextualReturnType = narrowedReturnType;
|
|
87780
|
-
}
|
|
87781
|
-
}
|
|
87782
|
-
const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
|
|
87783
|
-
const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
87784
|
-
narrowedExprType,
|
|
87785
|
-
/*withAlias*/
|
|
87786
|
-
false,
|
|
87787
|
-
node,
|
|
87788
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
87789
|
-
) : narrowedExprType;
|
|
87790
|
-
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, expr);
|
|
87791
|
-
}
|
|
87792
|
-
function checkReturnConditionalExpression(container, returnType, node, expr) {
|
|
87793
|
-
checkExpression(expr.condition);
|
|
87794
|
-
checkReturnStatementExpression(container, returnType, node, expr.whenTrue);
|
|
87795
|
-
checkReturnStatementExpression(container, returnType, node, expr.whenFalse);
|
|
87796
|
-
}
|
|
87797
|
-
function getNarrowableTypeParameters(candidates) {
|
|
87798
|
-
const narrowableParams = [];
|
|
87799
|
-
for (const typeParam of candidates) {
|
|
87800
|
-
const constraint = getConstraintOfTypeParameter(typeParam);
|
|
87801
|
-
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
|
87802
|
-
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
|
87803
|
-
const container = typeParam.symbol.declarations[0].parent;
|
|
87804
|
-
if (!isFunctionLike(container)) continue;
|
|
87805
|
-
let reference;
|
|
87806
|
-
let hasInvalidReference = false;
|
|
87807
|
-
for (const paramDecl of container.parameters) {
|
|
87808
|
-
const typeNode = paramDecl.type;
|
|
87809
|
-
if (!typeNode) continue;
|
|
87810
|
-
if (isTypeParameterReferenced(typeParam, typeNode)) {
|
|
87811
|
-
let candidateReference;
|
|
87812
|
-
if (isTypeReferenceNode(typeNode) && isReferenceToTypeParameter(typeParam, typeNode) && (candidateReference = getValidParameterReference(paramDecl, constraint))) {
|
|
87813
|
-
if (reference) {
|
|
87814
|
-
hasInvalidReference = true;
|
|
87815
|
-
break;
|
|
87816
|
-
}
|
|
87817
|
-
reference = candidateReference;
|
|
87818
|
-
continue;
|
|
87819
|
-
}
|
|
87820
|
-
hasInvalidReference = true;
|
|
87821
|
-
break;
|
|
87822
|
-
}
|
|
87823
|
-
}
|
|
87824
|
-
if (!hasInvalidReference && reference) {
|
|
87825
|
-
const symbol = getResolvedSymbol(reference);
|
|
87826
|
-
if (symbol !== unknownSymbol) narrowableParams.push([typeParam, symbol, reference]);
|
|
87827
|
-
}
|
|
87828
|
-
}
|
|
87829
|
-
}
|
|
87830
|
-
return narrowableParams;
|
|
87831
|
-
function getValidParameterReference(paramDecl, constraint) {
|
|
87832
|
-
if (!isIdentifier(paramDecl.name)) return;
|
|
87833
|
-
if (paramDecl.questionToken && !containsUndefinedType(constraint)) return;
|
|
87834
|
-
return paramDecl.name;
|
|
87835
|
-
}
|
|
87836
|
-
function isReferenceToTypeParameter(typeParam, node) {
|
|
87837
|
-
return getTypeFromTypeReference(node) === typeParam;
|
|
87838
|
-
}
|
|
87839
|
-
function isTypeParameterReferenced(typeParam, node) {
|
|
87840
|
-
return isReferenced(node);
|
|
87841
|
-
function isReferenced(node2) {
|
|
87842
|
-
if (isTypeReferenceNode(node2)) {
|
|
87843
|
-
return isReferenceToTypeParameter(typeParam, node2);
|
|
87844
|
-
}
|
|
87845
|
-
if (isTypeQueryNode(node2)) {
|
|
87846
|
-
return isTypeParameterPossiblyReferenced(typeParam, node2);
|
|
87847
|
-
}
|
|
87848
|
-
return !!forEachChild(node2, isReferenced);
|
|
87849
|
-
}
|
|
87850
|
-
}
|
|
87851
|
-
}
|
|
87852
|
-
function isNarrowableReturnType(returnType) {
|
|
87853
|
-
return isConditionalType(returnType) ? isNarrowableConditionalType(returnType) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
|
|
87854
|
-
}
|
|
87855
|
-
function isNarrowableConditionalType(type, mapper) {
|
|
87856
|
-
const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
|
|
87857
|
-
const mapped = getMappedType(t, mapper);
|
|
87858
|
-
if (isNarrowingSubstitutionType(mapped)) {
|
|
87859
|
-
return mapped.baseType;
|
|
87860
|
-
}
|
|
87861
|
-
return mapped;
|
|
87862
|
-
});
|
|
87863
|
-
const id = `${type.id}:${getTypeListId(typeArguments)}`;
|
|
87864
|
-
let result = narrowableReturnTypeCache.get(id);
|
|
87865
|
-
if (result === void 0) {
|
|
87866
|
-
const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
|
|
87867
|
-
const instantiatedType = instantiateType(type, nonNarrowingMapper);
|
|
87868
|
-
result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType);
|
|
87869
|
-
narrowableReturnTypeCache.set(id, result);
|
|
87870
|
-
}
|
|
87871
|
-
return result;
|
|
87872
|
-
}
|
|
87873
|
-
function isNarrowableConditionalTypeWorker(type) {
|
|
87874
|
-
if (!type.root.isDistributive) {
|
|
87875
|
-
return false;
|
|
87876
|
-
}
|
|
87877
|
-
if (type.root.inferTypeParameters) {
|
|
87878
|
-
return false;
|
|
87879
|
-
}
|
|
87880
|
-
if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
87881
|
-
return false;
|
|
87882
|
-
}
|
|
87883
|
-
const constraintType = getConstraintOfTypeParameter(type.checkType);
|
|
87884
|
-
if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
|
|
87885
|
-
return false;
|
|
87886
|
-
}
|
|
87887
|
-
if (!everyType(type.extendsType, (extendsType) => some(
|
|
87888
|
-
constraintType.types,
|
|
87889
|
-
(constraintType2) => isTypeIdenticalTo(constraintType2, extendsType)
|
|
87890
|
-
))) {
|
|
87891
|
-
return false;
|
|
87892
|
-
}
|
|
87893
|
-
const trueType2 = getTrueTypeFromConditionalType(type);
|
|
87894
|
-
const falseType2 = getFalseTypeFromConditionalType(type);
|
|
87895
|
-
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2) : true;
|
|
87896
|
-
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2) : falseType2 === neverType;
|
|
87897
|
-
return isValidTrueType && isValidFalseType;
|
|
87898
|
-
}
|
|
87899
|
-
function isConditionalType(type) {
|
|
87900
|
-
return !!(type.flags & 16777216 /* Conditional */);
|
|
87901
|
-
}
|
|
87902
87677
|
function checkWithStatement(node) {
|
|
87903
87678
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
87904
87679
|
if (node.flags & 65536 /* AwaitContext */) {
|
|
@@ -88827,6 +88602,9 @@ function createTypeChecker(host) {
|
|
|
88827
88602
|
}
|
|
88828
88603
|
function checkInterfaceDeclaration(node) {
|
|
88829
88604
|
if (!checkGrammarModifiers(node)) checkGrammarInterfaceDeclaration(node);
|
|
88605
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
88606
|
+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "interface");
|
|
88607
|
+
}
|
|
88830
88608
|
checkTypeParameters(node.typeParameters);
|
|
88831
88609
|
addLazyDiagnostic(() => {
|
|
88832
88610
|
checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0);
|
|
@@ -88861,6 +88639,9 @@ function createTypeChecker(host) {
|
|
|
88861
88639
|
function checkTypeAliasDeclaration(node) {
|
|
88862
88640
|
checkGrammarModifiers(node);
|
|
88863
88641
|
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
|
|
88642
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
88643
|
+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "type");
|
|
88644
|
+
}
|
|
88864
88645
|
checkExportsOnMergedDeclarations(node);
|
|
88865
88646
|
checkTypeParameters(node.typeParameters);
|
|
88866
88647
|
if (node.type.kind === 141 /* IntrinsicKeyword */) {
|
|
@@ -91247,7 +91028,7 @@ function createTypeChecker(host) {
|
|
|
91247
91028
|
const typeNode = getNonlocalEffectiveTypeAnnotationNode(parameter);
|
|
91248
91029
|
if (!typeNode) return false;
|
|
91249
91030
|
const type = getTypeFromTypeNode(typeNode);
|
|
91250
|
-
return containsUndefinedType(type);
|
|
91031
|
+
return isErrorType(type) || containsUndefinedType(type);
|
|
91251
91032
|
}
|
|
91252
91033
|
function requiresAddingImplicitUndefined(parameter, enclosingDeclaration) {
|
|
91253
91034
|
return (isRequiredInitializedParameter(parameter, enclosingDeclaration) || isOptionalUninitializedParameterProperty(parameter)) && !declaredParameterTypeContainsUndefined(parameter);
|
|
@@ -93273,7 +93054,7 @@ function createTypeChecker(host) {
|
|
|
93273
93054
|
}
|
|
93274
93055
|
return false;
|
|
93275
93056
|
}
|
|
93276
|
-
function
|
|
93057
|
+
function allowBlockDeclarations(parent2) {
|
|
93277
93058
|
switch (parent2.kind) {
|
|
93278
93059
|
case 245 /* IfStatement */:
|
|
93279
93060
|
case 246 /* DoStatement */:
|
|
@@ -93284,12 +93065,12 @@ function createTypeChecker(host) {
|
|
|
93284
93065
|
case 250 /* ForOfStatement */:
|
|
93285
93066
|
return false;
|
|
93286
93067
|
case 256 /* LabeledStatement */:
|
|
93287
|
-
return
|
|
93068
|
+
return allowBlockDeclarations(parent2.parent);
|
|
93288
93069
|
}
|
|
93289
93070
|
return true;
|
|
93290
93071
|
}
|
|
93291
93072
|
function checkGrammarForDisallowedBlockScopedVariableStatement(node) {
|
|
93292
|
-
if (!
|
|
93073
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
93293
93074
|
const blockScopeKind = getCombinedNodeFlagsCached(node.declarationList) & 7 /* BlockScoped */;
|
|
93294
93075
|
if (blockScopeKind) {
|
|
93295
93076
|
const keyword = blockScopeKind === 1 /* Let */ ? "let" : blockScopeKind === 2 /* Const */ ? "const" : blockScopeKind === 4 /* Using */ ? "using" : blockScopeKind === 6 /* AwaitUsing */ ? "await using" : Debug.fail("Unknown BlockScope flag");
|
|
@@ -96067,9 +95848,9 @@ function getDecoratorsOfParameters(node) {
|
|
|
96067
95848
|
}
|
|
96068
95849
|
return decorators;
|
|
96069
95850
|
}
|
|
96070
|
-
function getAllDecoratorsOfClass(node) {
|
|
95851
|
+
function getAllDecoratorsOfClass(node, useLegacyDecorators) {
|
|
96071
95852
|
const decorators = getDecorators(node);
|
|
96072
|
-
const parameters = getDecoratorsOfParameters(getFirstConstructorWithBody(node));
|
|
95853
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(getFirstConstructorWithBody(node)) : void 0;
|
|
96073
95854
|
if (!some(decorators) && !some(parameters)) {
|
|
96074
95855
|
return void 0;
|
|
96075
95856
|
}
|
|
@@ -96083,18 +95864,27 @@ function getAllDecoratorsOfClassElement(member, parent2, useLegacyDecorators) {
|
|
|
96083
95864
|
case 177 /* GetAccessor */:
|
|
96084
95865
|
case 178 /* SetAccessor */:
|
|
96085
95866
|
if (!useLegacyDecorators) {
|
|
96086
|
-
return getAllDecoratorsOfMethod(
|
|
95867
|
+
return getAllDecoratorsOfMethod(
|
|
95868
|
+
member,
|
|
95869
|
+
/*useLegacyDecorators*/
|
|
95870
|
+
false
|
|
95871
|
+
);
|
|
96087
95872
|
}
|
|
96088
|
-
return getAllDecoratorsOfAccessors(
|
|
95873
|
+
return getAllDecoratorsOfAccessors(
|
|
95874
|
+
member,
|
|
95875
|
+
parent2,
|
|
95876
|
+
/*useLegacyDecorators*/
|
|
95877
|
+
true
|
|
95878
|
+
);
|
|
96089
95879
|
case 174 /* MethodDeclaration */:
|
|
96090
|
-
return getAllDecoratorsOfMethod(member);
|
|
95880
|
+
return getAllDecoratorsOfMethod(member, useLegacyDecorators);
|
|
96091
95881
|
case 172 /* PropertyDeclaration */:
|
|
96092
95882
|
return getAllDecoratorsOfProperty(member);
|
|
96093
95883
|
default:
|
|
96094
95884
|
return void 0;
|
|
96095
95885
|
}
|
|
96096
95886
|
}
|
|
96097
|
-
function getAllDecoratorsOfAccessors(accessor, parent2) {
|
|
95887
|
+
function getAllDecoratorsOfAccessors(accessor, parent2, useLegacyDecorators) {
|
|
96098
95888
|
if (!accessor.body) {
|
|
96099
95889
|
return void 0;
|
|
96100
95890
|
}
|
|
@@ -96104,7 +95894,7 @@ function getAllDecoratorsOfAccessors(accessor, parent2) {
|
|
|
96104
95894
|
return void 0;
|
|
96105
95895
|
}
|
|
96106
95896
|
const decorators = getDecorators(firstAccessorWithDecorators);
|
|
96107
|
-
const parameters = getDecoratorsOfParameters(setAccessor);
|
|
95897
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(setAccessor) : void 0;
|
|
96108
95898
|
if (!some(decorators) && !some(parameters)) {
|
|
96109
95899
|
return void 0;
|
|
96110
95900
|
}
|
|
@@ -96115,12 +95905,12 @@ function getAllDecoratorsOfAccessors(accessor, parent2) {
|
|
|
96115
95905
|
setDecorators: setAccessor && getDecorators(setAccessor)
|
|
96116
95906
|
};
|
|
96117
95907
|
}
|
|
96118
|
-
function getAllDecoratorsOfMethod(method) {
|
|
95908
|
+
function getAllDecoratorsOfMethod(method, useLegacyDecorators) {
|
|
96119
95909
|
if (!method.body) {
|
|
96120
95910
|
return void 0;
|
|
96121
95911
|
}
|
|
96122
95912
|
const decorators = getDecorators(method);
|
|
96123
|
-
const parameters = getDecoratorsOfParameters(method);
|
|
95913
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(method) : void 0;
|
|
96124
95914
|
if (!some(decorators) && !some(parameters)) {
|
|
96125
95915
|
return void 0;
|
|
96126
95916
|
}
|
|
@@ -101764,7 +101554,11 @@ function transformLegacyDecorators(context) {
|
|
|
101764
101554
|
}
|
|
101765
101555
|
}
|
|
101766
101556
|
function generateConstructorDecorationExpression(node) {
|
|
101767
|
-
const allDecorators = getAllDecoratorsOfClass(
|
|
101557
|
+
const allDecorators = getAllDecoratorsOfClass(
|
|
101558
|
+
node,
|
|
101559
|
+
/*useLegacyDecorators*/
|
|
101560
|
+
true
|
|
101561
|
+
);
|
|
101768
101562
|
const decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
|
|
101769
101563
|
if (!decoratorExpressions) {
|
|
101770
101564
|
return void 0;
|
|
@@ -102276,7 +102070,11 @@ function transformESDecorators(context) {
|
|
|
102276
102070
|
let syntheticConstructor;
|
|
102277
102071
|
let heritageClauses;
|
|
102278
102072
|
let shouldTransformPrivateStaticElementsInClass = false;
|
|
102279
|
-
const classDecorators = transformAllDecoratorsOfDeclaration(getAllDecoratorsOfClass(
|
|
102073
|
+
const classDecorators = transformAllDecoratorsOfDeclaration(getAllDecoratorsOfClass(
|
|
102074
|
+
node,
|
|
102075
|
+
/*useLegacyDecorators*/
|
|
102076
|
+
false
|
|
102077
|
+
));
|
|
102280
102078
|
if (classDecorators) {
|
|
102281
102079
|
classInfo2.classDecoratorsName = factory2.createUniqueName("_classDecorators", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
102282
102080
|
classInfo2.classDescriptorName = factory2.createUniqueName("_classDescriptor", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
@@ -121782,15 +121580,88 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
121782
121580
|
return false;
|
|
121783
121581
|
}
|
|
121784
121582
|
function parenthesizeExpressionForNoAsi(node) {
|
|
121785
|
-
if (!commentsDisabled
|
|
121786
|
-
|
|
121787
|
-
|
|
121788
|
-
|
|
121789
|
-
|
|
121790
|
-
|
|
121791
|
-
|
|
121583
|
+
if (!commentsDisabled) {
|
|
121584
|
+
switch (node.kind) {
|
|
121585
|
+
case 355 /* PartiallyEmittedExpression */:
|
|
121586
|
+
if (willEmitLeadingNewLine(node)) {
|
|
121587
|
+
const parseNode = getParseTreeNode(node);
|
|
121588
|
+
if (parseNode && isParenthesizedExpression(parseNode)) {
|
|
121589
|
+
const parens = factory.createParenthesizedExpression(node.expression);
|
|
121590
|
+
setOriginalNode(parens, node);
|
|
121591
|
+
setTextRange(parens, parseNode);
|
|
121592
|
+
return parens;
|
|
121593
|
+
}
|
|
121594
|
+
return factory.createParenthesizedExpression(node);
|
|
121595
|
+
}
|
|
121596
|
+
return factory.updatePartiallyEmittedExpression(
|
|
121597
|
+
node,
|
|
121598
|
+
parenthesizeExpressionForNoAsi(node.expression)
|
|
121599
|
+
);
|
|
121600
|
+
case 211 /* PropertyAccessExpression */:
|
|
121601
|
+
return factory.updatePropertyAccessExpression(
|
|
121602
|
+
node,
|
|
121603
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
121604
|
+
node.name
|
|
121605
|
+
);
|
|
121606
|
+
case 212 /* ElementAccessExpression */:
|
|
121607
|
+
return factory.updateElementAccessExpression(
|
|
121608
|
+
node,
|
|
121609
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
121610
|
+
node.argumentExpression
|
|
121611
|
+
);
|
|
121612
|
+
case 213 /* CallExpression */:
|
|
121613
|
+
return factory.updateCallExpression(
|
|
121614
|
+
node,
|
|
121615
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
121616
|
+
node.typeArguments,
|
|
121617
|
+
node.arguments
|
|
121618
|
+
);
|
|
121619
|
+
case 215 /* TaggedTemplateExpression */:
|
|
121620
|
+
return factory.updateTaggedTemplateExpression(
|
|
121621
|
+
node,
|
|
121622
|
+
parenthesizeExpressionForNoAsi(node.tag),
|
|
121623
|
+
node.typeArguments,
|
|
121624
|
+
node.template
|
|
121625
|
+
);
|
|
121626
|
+
case 225 /* PostfixUnaryExpression */:
|
|
121627
|
+
return factory.updatePostfixUnaryExpression(
|
|
121628
|
+
node,
|
|
121629
|
+
parenthesizeExpressionForNoAsi(node.operand)
|
|
121630
|
+
);
|
|
121631
|
+
case 226 /* BinaryExpression */:
|
|
121632
|
+
return factory.updateBinaryExpression(
|
|
121633
|
+
node,
|
|
121634
|
+
parenthesizeExpressionForNoAsi(node.left),
|
|
121635
|
+
node.operatorToken,
|
|
121636
|
+
node.right
|
|
121637
|
+
);
|
|
121638
|
+
case 227 /* ConditionalExpression */:
|
|
121639
|
+
return factory.updateConditionalExpression(
|
|
121640
|
+
node,
|
|
121641
|
+
parenthesizeExpressionForNoAsi(node.condition),
|
|
121642
|
+
node.questionToken,
|
|
121643
|
+
node.whenTrue,
|
|
121644
|
+
node.colonToken,
|
|
121645
|
+
node.whenFalse
|
|
121646
|
+
);
|
|
121647
|
+
case 234 /* AsExpression */:
|
|
121648
|
+
return factory.updateAsExpression(
|
|
121649
|
+
node,
|
|
121650
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
121651
|
+
node.type
|
|
121652
|
+
);
|
|
121653
|
+
case 238 /* SatisfiesExpression */:
|
|
121654
|
+
return factory.updateSatisfiesExpression(
|
|
121655
|
+
node,
|
|
121656
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
121657
|
+
node.type
|
|
121658
|
+
);
|
|
121659
|
+
case 235 /* NonNullExpression */:
|
|
121660
|
+
return factory.updateNonNullExpression(
|
|
121661
|
+
node,
|
|
121662
|
+
parenthesizeExpressionForNoAsi(node.expression)
|
|
121663
|
+
);
|
|
121792
121664
|
}
|
|
121793
|
-
return factory.createParenthesizedExpression(node);
|
|
121794
121665
|
}
|
|
121795
121666
|
return node;
|
|
121796
121667
|
}
|
|
@@ -140630,7 +140501,13 @@ function getDefaultLikeExportNameFromDeclaration(symbol) {
|
|
|
140630
140501
|
if (isExportSpecifier(d) && d.symbol.flags === 2097152 /* Alias */) {
|
|
140631
140502
|
return (_b = tryCast(d.propertyName, isIdentifier)) == null ? void 0 : _b.text;
|
|
140632
140503
|
}
|
|
140633
|
-
|
|
140504
|
+
const name = (_c = tryCast(getNameOfDeclaration(d), isIdentifier)) == null ? void 0 : _c.text;
|
|
140505
|
+
if (name) {
|
|
140506
|
+
return name;
|
|
140507
|
+
}
|
|
140508
|
+
if (symbol.parent && !isExternalModuleSymbol(symbol.parent)) {
|
|
140509
|
+
return symbol.parent.getName();
|
|
140510
|
+
}
|
|
140634
140511
|
});
|
|
140635
140512
|
}
|
|
140636
140513
|
function getSymbolParentOrFail(symbol) {
|
|
@@ -141221,7 +141098,7 @@ function getExportInfoMap(importingFile, host, program, preferences, cancellatio
|
|
|
141221
141098
|
true,
|
|
141222
141099
|
(moduleSymbol, moduleFile, program2, isFromPackageJson) => {
|
|
141223
141100
|
if (++moduleCount % 100 === 0) cancellationToken == null ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
141224
|
-
const seenExports = /* @__PURE__ */ new
|
|
141101
|
+
const seenExports = /* @__PURE__ */ new Set();
|
|
141225
141102
|
const checker = program2.getTypeChecker();
|
|
141226
141103
|
const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker);
|
|
141227
141104
|
if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
|
|
@@ -141261,7 +141138,11 @@ function getExportInfoMap(importingFile, host, program, preferences, cancellatio
|
|
|
141261
141138
|
}
|
|
141262
141139
|
function getDefaultLikeExportInfo(moduleSymbol, checker) {
|
|
141263
141140
|
const exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol);
|
|
141264
|
-
if (exportEquals !== moduleSymbol)
|
|
141141
|
+
if (exportEquals !== moduleSymbol) {
|
|
141142
|
+
const defaultExport2 = checker.tryGetMemberInModuleExports("default" /* Default */, exportEquals);
|
|
141143
|
+
if (defaultExport2) return { symbol: defaultExport2, exportKind: 1 /* Default */ };
|
|
141144
|
+
return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ };
|
|
141145
|
+
}
|
|
141265
141146
|
const defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol);
|
|
141266
141147
|
if (defaultExport) return { symbol: defaultExport, exportKind: 1 /* Default */ };
|
|
141267
141148
|
}
|
|
@@ -141279,7 +141160,7 @@ function getNamesForExportedSymbol(defaultExport, checker, scriptTarget) {
|
|
|
141279
141160
|
function forEachNameOfDefaultExport(defaultExport, checker, scriptTarget, cb) {
|
|
141280
141161
|
let chain;
|
|
141281
141162
|
let current = defaultExport;
|
|
141282
|
-
const seen = /* @__PURE__ */ new
|
|
141163
|
+
const seen = /* @__PURE__ */ new Set();
|
|
141283
141164
|
while (current) {
|
|
141284
141165
|
const fromDeclaration = getDefaultLikeExportNameFromDeclaration(current);
|
|
141285
141166
|
if (fromDeclaration) {
|
|
@@ -144828,6 +144709,7 @@ function isSynthesized(node) {
|
|
|
144828
144709
|
return !!(node.flags & 16 /* Synthesized */);
|
|
144829
144710
|
}
|
|
144830
144711
|
function isOwnChild(n, parent2) {
|
|
144712
|
+
if (n.parent === void 0) return false;
|
|
144831
144713
|
const par = isModuleBlock(n.parent) ? n.parent.parent : n.parent;
|
|
144832
144714
|
return par === parent2.node || contains(parent2.additionalNodes, par);
|
|
144833
144715
|
}
|
|
@@ -145744,7 +145626,7 @@ function flattenTypeLiteralNodeReference(checker, selection) {
|
|
|
145744
145626
|
}
|
|
145745
145627
|
if (isIntersectionTypeNode(selection)) {
|
|
145746
145628
|
const result = [];
|
|
145747
|
-
const seen = /* @__PURE__ */ new
|
|
145629
|
+
const seen = /* @__PURE__ */ new Set();
|
|
145748
145630
|
for (const type of selection.types) {
|
|
145749
145631
|
const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type);
|
|
145750
145632
|
if (!flattenedTypeMembers || !flattenedTypeMembers.every((type2) => type2.name && addToSeen(seen, getNameFromPropertyName(type2.name)))) {
|
|
@@ -156416,7 +156298,7 @@ registerCodeFix({
|
|
|
156416
156298
|
},
|
|
156417
156299
|
fixIds: [fixId13],
|
|
156418
156300
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyExport(context) {
|
|
156419
|
-
const fixedExportDeclarations = /* @__PURE__ */ new
|
|
156301
|
+
const fixedExportDeclarations = /* @__PURE__ */ new Set();
|
|
156420
156302
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
156421
156303
|
const exportSpecifier = getExportSpecifierForDiagnosticSpan(diag2, context.sourceFile);
|
|
156422
156304
|
if (exportSpecifier && addToSeen(fixedExportDeclarations, getNodeId(exportSpecifier.parent.parent))) {
|
|
@@ -156895,7 +156777,7 @@ registerCodeFix({
|
|
|
156895
156777
|
},
|
|
156896
156778
|
fixIds: [fixId17],
|
|
156897
156779
|
getAllCodeActions(context) {
|
|
156898
|
-
const seenClassDeclarations = /* @__PURE__ */ new
|
|
156780
|
+
const seenClassDeclarations = /* @__PURE__ */ new Set();
|
|
156899
156781
|
return codeFixAll(context, errorCodes18, (changes, diag2) => {
|
|
156900
156782
|
const classDeclaration = getClass(diag2.file, diag2.start);
|
|
156901
156783
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
@@ -157276,7 +157158,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
157276
157158
|
function writeFixes(changeTracker, oldFileQuotePreference) {
|
|
157277
157159
|
var _a, _b;
|
|
157278
157160
|
let quotePreference;
|
|
157279
|
-
if (
|
|
157161
|
+
if (sourceFile.imports !== void 0 && sourceFile.imports.length === 0 && oldFileQuotePreference !== void 0) {
|
|
157280
157162
|
quotePreference = oldFileQuotePreference;
|
|
157281
157163
|
} else {
|
|
157282
157164
|
quotePreference = getQuotePreference(sourceFile, preferences);
|
|
@@ -158522,7 +158404,7 @@ registerCodeFix({
|
|
|
158522
158404
|
fixIds: [fixId18],
|
|
158523
158405
|
getAllCodeActions: (context) => {
|
|
158524
158406
|
const { program, preferences, host } = context;
|
|
158525
|
-
const seen = /* @__PURE__ */ new
|
|
158407
|
+
const seen = /* @__PURE__ */ new Set();
|
|
158526
158408
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
158527
158409
|
eachDiagnostic(context, errorCodes20, (diag2) => {
|
|
158528
158410
|
const info = getInfo6(program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
@@ -159456,7 +159338,7 @@ registerCodeFix({
|
|
|
159456
159338
|
getAllCodeActions: (context) => {
|
|
159457
159339
|
const { program, fixId: fixId56 } = context;
|
|
159458
159340
|
const checker = program.getTypeChecker();
|
|
159459
|
-
const seen = /* @__PURE__ */ new
|
|
159341
|
+
const seen = /* @__PURE__ */ new Set();
|
|
159460
159342
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
159461
159343
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
159462
159344
|
eachDiagnostic(context, errorCodes28, (diag2) => {
|
|
@@ -159507,7 +159389,7 @@ registerCodeFix({
|
|
|
159507
159389
|
}
|
|
159508
159390
|
});
|
|
159509
159391
|
function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
159510
|
-
var _a;
|
|
159392
|
+
var _a, _b, _c;
|
|
159511
159393
|
const token = getTokenAtPosition(sourceFile, tokenPos);
|
|
159512
159394
|
const parent2 = token.parent;
|
|
159513
159395
|
if (errorCode === Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) {
|
|
@@ -159520,7 +159402,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
159520
159402
|
if (!(param && isParameter(param) && isIdentifier(param.name))) return void 0;
|
|
159521
159403
|
const properties = arrayFrom(checker.getUnmatchedProperties(
|
|
159522
159404
|
checker.getTypeAtLocation(parent2),
|
|
159523
|
-
checker.getParameterType(signature, argIndex),
|
|
159405
|
+
checker.getParameterType(signature, argIndex).getNonNullableType(),
|
|
159524
159406
|
/*requireOptionalProperties*/
|
|
159525
159407
|
false,
|
|
159526
159408
|
/*matchDiscriminantProperties*/
|
|
@@ -159530,7 +159412,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
159530
159412
|
return { kind: 3 /* ObjectLiteral */, token: param.name, identifier: param.name.text, properties, parentDeclaration: parent2 };
|
|
159531
159413
|
}
|
|
159532
159414
|
if (token.kind === 19 /* OpenBraceToken */ && isObjectLiteralExpression(parent2)) {
|
|
159533
|
-
const targetType = checker.getContextualType(parent2) || checker.getTypeAtLocation(parent2);
|
|
159415
|
+
const targetType = (_a = checker.getContextualType(parent2) || checker.getTypeAtLocation(parent2)) == null ? void 0 : _a.getNonNullableType();
|
|
159534
159416
|
const properties = arrayFrom(checker.getUnmatchedProperties(
|
|
159535
159417
|
checker.getTypeAtLocation(parent2),
|
|
159536
159418
|
targetType,
|
|
@@ -159545,7 +159427,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
159545
159427
|
}
|
|
159546
159428
|
if (!isMemberName(token)) return void 0;
|
|
159547
159429
|
if (isIdentifier(token) && hasInitializer(parent2) && parent2.initializer && isObjectLiteralExpression(parent2.initializer)) {
|
|
159548
|
-
const targetType = checker.getContextualType(token) || checker.getTypeAtLocation(token);
|
|
159430
|
+
const targetType = (_b = checker.getContextualType(token) || checker.getTypeAtLocation(token)) == null ? void 0 : _b.getNonNullableType();
|
|
159549
159431
|
const properties = arrayFrom(checker.getUnmatchedProperties(
|
|
159550
159432
|
checker.getTypeAtLocation(parent2.initializer),
|
|
159551
159433
|
targetType,
|
|
@@ -159564,7 +159446,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
159564
159446
|
return { kind: 4 /* JsxAttributes */, token, attributes, parentDeclaration: token.parent };
|
|
159565
159447
|
}
|
|
159566
159448
|
if (isIdentifier(token)) {
|
|
159567
|
-
const type = (
|
|
159449
|
+
const type = (_c = checker.getContextualType(token)) == null ? void 0 : _c.getNonNullableType();
|
|
159568
159450
|
if (type && getObjectFlags(type) & 16 /* Anonymous */) {
|
|
159569
159451
|
const signature = firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
|
|
159570
159452
|
if (signature === void 0) return void 0;
|
|
@@ -159885,8 +159767,9 @@ function tryGetValueFromType(context, checker, importAdder, quotePreference, typ
|
|
|
159885
159767
|
}
|
|
159886
159768
|
if (type.flags & 1056 /* EnumLike */) {
|
|
159887
159769
|
const enumMember = type.symbol.exports ? firstOrUndefinedIterator(type.symbol.exports.values()) : type.symbol;
|
|
159770
|
+
const symbol = type.symbol.parent && type.symbol.parent.flags & 256 /* RegularEnum */ ? type.symbol.parent : type.symbol;
|
|
159888
159771
|
const name = checker.symbolToExpression(
|
|
159889
|
-
|
|
159772
|
+
symbol,
|
|
159890
159773
|
111551 /* Value */,
|
|
159891
159774
|
/*enclosingDeclaration*/
|
|
159892
159775
|
void 0,
|
|
@@ -160380,7 +160263,7 @@ registerCodeFix({
|
|
|
160380
160263
|
},
|
|
160381
160264
|
fixIds: [fixId26],
|
|
160382
160265
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
160383
|
-
const seenClassDeclarations = /* @__PURE__ */ new
|
|
160266
|
+
const seenClassDeclarations = /* @__PURE__ */ new Set();
|
|
160384
160267
|
return codeFixAll(context, errorCodes32, (changes, diag2) => {
|
|
160385
160268
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
160386
160269
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
@@ -160423,7 +160306,7 @@ registerCodeFix({
|
|
|
160423
160306
|
fixIds: [fixId27],
|
|
160424
160307
|
getAllCodeActions(context) {
|
|
160425
160308
|
const { sourceFile } = context;
|
|
160426
|
-
const seenClasses = /* @__PURE__ */ new
|
|
160309
|
+
const seenClasses = /* @__PURE__ */ new Set();
|
|
160427
160310
|
return codeFixAll(context, errorCodes33, (changes, diag2) => {
|
|
160428
160311
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
160429
160312
|
if (!nodes) return;
|
|
@@ -162367,7 +162250,7 @@ registerCodeFix({
|
|
|
162367
162250
|
},
|
|
162368
162251
|
fixIds: [fixId38],
|
|
162369
162252
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
162370
|
-
const seen = /* @__PURE__ */ new
|
|
162253
|
+
const seen = /* @__PURE__ */ new Set();
|
|
162371
162254
|
return codeFixAll(context, errorCodes49, (changes, diag2) => {
|
|
162372
162255
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
162373
162256
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore))) return;
|
|
@@ -165233,7 +165116,7 @@ registerCodeFix({
|
|
|
165233
165116
|
},
|
|
165234
165117
|
getAllCodeActions: (context) => {
|
|
165235
165118
|
const { program } = context;
|
|
165236
|
-
const seen = /* @__PURE__ */ new
|
|
165119
|
+
const seen = /* @__PURE__ */ new Set();
|
|
165237
165120
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
165238
165121
|
eachDiagnostic(context, errorCodes65, (diag2) => {
|
|
165239
165122
|
const info = getInfo21(diag2.file, diag2.start, program);
|
|
@@ -167672,7 +167555,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
167672
167555
|
let importSpecifierResolver;
|
|
167673
167556
|
const symbolToOriginInfoMap = [];
|
|
167674
167557
|
const symbolToSortTextMap = [];
|
|
167675
|
-
const seenPropertySymbols = /* @__PURE__ */ new
|
|
167558
|
+
const seenPropertySymbols = /* @__PURE__ */ new Set();
|
|
167676
167559
|
const isTypeOnlyLocation = isTypeOnlyCompletion();
|
|
167677
167560
|
const getModuleSpecifierResolutionHost = memoizeOne((isFromPackageJson) => {
|
|
167678
167561
|
return createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
|
|
@@ -169436,10 +169319,10 @@ function isArrowFunctionBody(node) {
|
|
|
169436
169319
|
return node.parent && isArrowFunction(node.parent) && (node.parent.body === node || // const a = () => /**/;
|
|
169437
169320
|
node.kind === 39 /* EqualsGreaterThanToken */);
|
|
169438
169321
|
}
|
|
169439
|
-
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules = /* @__PURE__ */ new
|
|
169322
|
+
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules = /* @__PURE__ */ new Set()) {
|
|
169440
169323
|
return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(skipAlias(symbol.exportSymbol || symbol, checker));
|
|
169441
169324
|
function nonAliasCanBeReferencedAtTypeLocation(symbol2) {
|
|
169442
|
-
return !!(symbol2.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol2) || !!(symbol2.flags & 1536 /* Module */) && addToSeen(seenModules,
|
|
169325
|
+
return !!(symbol2.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol2) || !!(symbol2.flags & 1536 /* Module */) && addToSeen(seenModules, symbol2) && checker.getExportsOfModule(symbol2).some((e) => symbolCanBeReferencedAtTypeLocation(e, checker, seenModules));
|
|
169443
169326
|
}
|
|
169444
169327
|
}
|
|
169445
169328
|
function isDeprecated(symbol, checker) {
|
|
@@ -169511,7 +169394,7 @@ function createNameAndKindSet() {
|
|
|
169511
169394
|
}
|
|
169512
169395
|
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences, includeSymbol) {
|
|
169513
169396
|
if (isInReferenceComment(sourceFile, position)) {
|
|
169514
|
-
const entries = getTripleSlashReferenceCompletion(sourceFile, position, program, host);
|
|
169397
|
+
const entries = getTripleSlashReferenceCompletion(sourceFile, position, program, host, createModuleSpecifierResolutionHost(program, host));
|
|
169515
169398
|
return entries && convertPathCompletions(entries);
|
|
169516
169399
|
}
|
|
169517
169400
|
if (isInString(sourceFile, position, contextToken)) {
|
|
@@ -169784,7 +169667,7 @@ function getAlreadyUsedTypesInStringLiteralUnion(union, current) {
|
|
|
169784
169667
|
}
|
|
169785
169668
|
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
169786
169669
|
let isNewIdentifier = false;
|
|
169787
|
-
const uniques = /* @__PURE__ */ new
|
|
169670
|
+
const uniques = /* @__PURE__ */ new Set();
|
|
169788
169671
|
const editingArgument = isJsxOpeningLikeElement(call) ? Debug.checkDefined(findAncestor(arg.parent, isJsxAttribute)) : arg;
|
|
169789
169672
|
const candidates = checker.getCandidateSignaturesForStringLiteralCompletions(call, editingArgument);
|
|
169790
169673
|
const types = flatMap(candidates, (candidate) => {
|
|
@@ -169824,7 +169707,7 @@ function stringLiteralCompletionsForObjectLiteral(checker, objectLiteralExpressi
|
|
|
169824
169707
|
hasIndexSignature: hasIndexSignature(contextualType)
|
|
169825
169708
|
};
|
|
169826
169709
|
}
|
|
169827
|
-
function getStringLiteralTypes(type, uniques = /* @__PURE__ */ new
|
|
169710
|
+
function getStringLiteralTypes(type, uniques = /* @__PURE__ */ new Set()) {
|
|
169828
169711
|
if (!type) return emptyArray;
|
|
169829
169712
|
type = skipConstraint(type);
|
|
169830
169713
|
return type.isUnion() ? flatMap(type.types, (t) => getStringLiteralTypes(t, uniques)) : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && addToSeen(uniques, type.value) ? [type] : emptyArray;
|
|
@@ -169855,8 +169738,9 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, prog
|
|
|
169855
169738
|
const scriptDirectory = getDirectoryPath(scriptPath);
|
|
169856
169739
|
const compilerOptions = program.getCompilerOptions();
|
|
169857
169740
|
const typeChecker = program.getTypeChecker();
|
|
169741
|
+
const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host);
|
|
169858
169742
|
const extensionOptions = getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile, typeChecker, preferences, mode);
|
|
169859
|
-
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, program, host, extensionOptions);
|
|
169743
|
+
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, moduleSpecifierResolutionHost, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, program, host, moduleSpecifierResolutionHost, extensionOptions);
|
|
169860
169744
|
}
|
|
169861
169745
|
function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile, typeChecker, preferences, resolutionMode) {
|
|
169862
169746
|
return {
|
|
@@ -169867,7 +169751,7 @@ function getExtensionOptions(compilerOptions, referenceKind, importingSourceFile
|
|
|
169867
169751
|
resolutionMode
|
|
169868
169752
|
};
|
|
169869
169753
|
}
|
|
169870
|
-
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, scriptPath, extensionOptions) {
|
|
169754
|
+
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, program, host, moduleSpecifierResolutionHost, scriptPath, extensionOptions) {
|
|
169871
169755
|
const compilerOptions = program.getCompilerOptions();
|
|
169872
169756
|
if (compilerOptions.rootDirs) {
|
|
169873
169757
|
return getCompletionEntriesForDirectoryFragmentWithRootDirs(
|
|
@@ -169877,6 +169761,7 @@ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, p
|
|
|
169877
169761
|
extensionOptions,
|
|
169878
169762
|
program,
|
|
169879
169763
|
host,
|
|
169764
|
+
moduleSpecifierResolutionHost,
|
|
169880
169765
|
scriptPath
|
|
169881
169766
|
);
|
|
169882
169767
|
} else {
|
|
@@ -169886,6 +169771,7 @@ function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, p
|
|
|
169886
169771
|
extensionOptions,
|
|
169887
169772
|
program,
|
|
169888
169773
|
host,
|
|
169774
|
+
moduleSpecifierResolutionHost,
|
|
169889
169775
|
/*moduleSpecifierIsRelative*/
|
|
169890
169776
|
true,
|
|
169891
169777
|
scriptPath
|
|
@@ -169911,7 +169797,7 @@ function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ign
|
|
|
169911
169797
|
compareStringsCaseSensitive
|
|
169912
169798
|
);
|
|
169913
169799
|
}
|
|
169914
|
-
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, program, host, exclude) {
|
|
169800
|
+
function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, exclude) {
|
|
169915
169801
|
const compilerOptions = program.getCompilerOptions();
|
|
169916
169802
|
const basePath = compilerOptions.project || host.getCurrentDirectory();
|
|
169917
169803
|
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
|
@@ -169923,6 +169809,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
|
169923
169809
|
extensionOptions,
|
|
169924
169810
|
program,
|
|
169925
169811
|
host,
|
|
169812
|
+
moduleSpecifierResolutionHost,
|
|
169926
169813
|
/*moduleSpecifierIsRelative*/
|
|
169927
169814
|
true,
|
|
169928
169815
|
exclude
|
|
@@ -169930,7 +169817,7 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment
|
|
|
169930
169817
|
(itemA, itemB) => itemA.name === itemB.name && itemA.kind === itemB.kind && itemA.extension === itemB.extension
|
|
169931
169818
|
);
|
|
169932
169819
|
}
|
|
169933
|
-
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, program, host, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
|
|
169820
|
+
function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, moduleSpecifierIsRelative, exclude, result = createNameAndKindSet()) {
|
|
169934
169821
|
var _a;
|
|
169935
169822
|
if (fragment === void 0) {
|
|
169936
169823
|
fragment = "";
|
|
@@ -169955,7 +169842,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
169955
169842
|
if (versionPaths) {
|
|
169956
169843
|
const packageDirectory = getDirectoryPath(packageJsonPath);
|
|
169957
169844
|
const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length);
|
|
169958
|
-
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, program, host, versionPaths)) {
|
|
169845
|
+
if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, versionPaths)) {
|
|
169959
169846
|
return result;
|
|
169960
169847
|
}
|
|
169961
169848
|
}
|
|
@@ -169983,7 +169870,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
169983
169870
|
getBaseFileName(filePath),
|
|
169984
169871
|
program,
|
|
169985
169872
|
extensionOptions,
|
|
169986
|
-
/*
|
|
169873
|
+
/*isExportsOrImportsWildcard*/
|
|
169987
169874
|
false
|
|
169988
169875
|
);
|
|
169989
169876
|
result.add(nameAndKind(name, "script" /* scriptElement */, extension));
|
|
@@ -170000,7 +169887,7 @@ function getCompletionEntriesForDirectoryFragment(fragment, scriptDirectory, ext
|
|
|
170000
169887
|
}
|
|
170001
169888
|
return result;
|
|
170002
169889
|
}
|
|
170003
|
-
function getFilenameWithExtensionOption(name, program, extensionOptions,
|
|
169890
|
+
function getFilenameWithExtensionOption(name, program, extensionOptions, isExportsOrImportsWildcard) {
|
|
170004
169891
|
const nonJsResult = ts_moduleSpecifiers_exports.tryGetRealFileNameForNonJsDeclarationFileName(name);
|
|
170005
169892
|
if (nonJsResult) {
|
|
170006
169893
|
return { name: nonJsResult, extension: tryGetExtensionFromPath2(nonJsResult) };
|
|
@@ -170014,7 +169901,7 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
|
170014
169901
|
program.getCompilerOptions(),
|
|
170015
169902
|
extensionOptions.importingSourceFile
|
|
170016
169903
|
).getAllowedEndingsInPreferredOrder(extensionOptions.resolutionMode);
|
|
170017
|
-
if (
|
|
169904
|
+
if (isExportsOrImportsWildcard) {
|
|
170018
169905
|
allowedEndings = allowedEndings.filter((e) => e !== 0 /* Minimal */ && e !== 1 /* Index */);
|
|
170019
169906
|
}
|
|
170020
169907
|
if (allowedEndings[0] === 3 /* TsExtension */) {
|
|
@@ -170024,13 +169911,13 @@ function getFilenameWithExtensionOption(name, program, extensionOptions, isExpor
|
|
|
170024
169911
|
const outputExtension2 = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, program.getCompilerOptions());
|
|
170025
169912
|
return outputExtension2 ? { name: changeExtension(name, outputExtension2), extension: outputExtension2 } : { name, extension: tryGetExtensionFromPath2(name) };
|
|
170026
169913
|
}
|
|
170027
|
-
if (!
|
|
169914
|
+
if (!isExportsOrImportsWildcard && (allowedEndings[0] === 0 /* Minimal */ || allowedEndings[0] === 1 /* Index */) && fileExtensionIsOneOf(name, [".js" /* Js */, ".jsx" /* Jsx */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */])) {
|
|
170028
169915
|
return { name: removeFileExtension(name), extension: tryGetExtensionFromPath2(name) };
|
|
170029
169916
|
}
|
|
170030
169917
|
const outputExtension = ts_moduleSpecifiers_exports.tryGetJSExtensionForFile(name, program.getCompilerOptions());
|
|
170031
169918
|
return outputExtension ? { name: changeExtension(name, outputExtension), extension: outputExtension } : { name, extension: tryGetExtensionFromPath2(name) };
|
|
170032
169919
|
}
|
|
170033
|
-
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, program, host, paths) {
|
|
169920
|
+
function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, paths) {
|
|
170034
169921
|
const getPatternsForKey = (key) => paths[key];
|
|
170035
169922
|
const comparePaths2 = (a, b) => {
|
|
170036
169923
|
const patternA = tryParsePattern(a);
|
|
@@ -170039,40 +169926,43 @@ function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensio
|
|
|
170039
169926
|
const lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length;
|
|
170040
169927
|
return compareValues(lengthB, lengthA);
|
|
170041
169928
|
};
|
|
170042
|
-
return
|
|
169929
|
+
return addCompletionEntriesFromPathsOrExportsOrImports(
|
|
170043
169930
|
result,
|
|
170044
169931
|
/*isExports*/
|
|
170045
169932
|
false,
|
|
169933
|
+
/*isImports*/
|
|
169934
|
+
false,
|
|
170046
169935
|
fragment,
|
|
170047
169936
|
baseDirectory,
|
|
170048
169937
|
extensionOptions,
|
|
170049
169938
|
program,
|
|
170050
169939
|
host,
|
|
169940
|
+
moduleSpecifierResolutionHost,
|
|
170051
169941
|
getOwnKeys(paths),
|
|
170052
169942
|
getPatternsForKey,
|
|
170053
169943
|
comparePaths2
|
|
170054
169944
|
);
|
|
170055
169945
|
}
|
|
170056
|
-
function
|
|
169946
|
+
function addCompletionEntriesFromPathsOrExportsOrImports(result, isExports, isImports, fragment, baseDirectory, extensionOptions, program, host, moduleSpecifierResolutionHost, keys, getPatternsForKey, comparePaths2) {
|
|
170057
169947
|
let pathResults = [];
|
|
170058
169948
|
let matchedPath;
|
|
170059
169949
|
for (const key of keys) {
|
|
170060
169950
|
if (key === ".") continue;
|
|
170061
|
-
const keyWithoutLeadingDotSlash = key.replace(/^\.\//, "");
|
|
169951
|
+
const keyWithoutLeadingDotSlash = key.replace(/^\.\//, "") + ((isExports || isImports) && endsWith(key, "/") ? "*" : "");
|
|
170062
169952
|
const patterns = getPatternsForKey(key);
|
|
170063
169953
|
if (patterns) {
|
|
170064
169954
|
const pathPattern = tryParsePattern(keyWithoutLeadingDotSlash);
|
|
170065
169955
|
if (!pathPattern) continue;
|
|
170066
169956
|
const isMatch = typeof pathPattern === "object" && isPatternMatch(pathPattern, fragment);
|
|
170067
|
-
const isLongestMatch = isMatch && (matchedPath === void 0 || comparePaths2(
|
|
169957
|
+
const isLongestMatch = isMatch && (matchedPath === void 0 || comparePaths2(keyWithoutLeadingDotSlash, matchedPath) === -1 /* LessThan */);
|
|
170068
169958
|
if (isLongestMatch) {
|
|
170069
|
-
matchedPath =
|
|
169959
|
+
matchedPath = keyWithoutLeadingDotSlash;
|
|
170070
169960
|
pathResults = pathResults.filter((r) => !r.matchedPattern);
|
|
170071
169961
|
}
|
|
170072
|
-
if (typeof pathPattern === "string" || matchedPath === void 0 || comparePaths2(
|
|
169962
|
+
if (typeof pathPattern === "string" || matchedPath === void 0 || comparePaths2(keyWithoutLeadingDotSlash, matchedPath) !== 1 /* GreaterThan */) {
|
|
170073
169963
|
pathResults.push({
|
|
170074
169964
|
matchedPattern: isMatch,
|
|
170075
|
-
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports
|
|
169965
|
+
results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost).map(({ name, kind, extension }) => nameAndKind(name, kind, extension))
|
|
170076
169966
|
});
|
|
170077
169967
|
}
|
|
170078
169968
|
}
|
|
@@ -170080,7 +169970,7 @@ function addCompletionEntriesFromPathsOrExports(result, isExports, fragment, bas
|
|
|
170080
169970
|
pathResults.forEach((pathResult) => pathResult.results.forEach((r) => result.add(r)));
|
|
170081
169971
|
return matchedPath !== void 0;
|
|
170082
169972
|
}
|
|
170083
|
-
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, program, host, extensionOptions) {
|
|
169973
|
+
function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, program, host, moduleSpecifierResolutionHost, extensionOptions) {
|
|
170084
169974
|
const typeChecker = program.getTypeChecker();
|
|
170085
169975
|
const compilerOptions = program.getCompilerOptions();
|
|
170086
169976
|
const { baseUrl, paths } = compilerOptions;
|
|
@@ -170094,6 +169984,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
170094
169984
|
extensionOptions,
|
|
170095
169985
|
program,
|
|
170096
169986
|
host,
|
|
169987
|
+
moduleSpecifierResolutionHost,
|
|
170097
169988
|
/*moduleSpecifierIsRelative*/
|
|
170098
169989
|
false,
|
|
170099
169990
|
/*exclude*/
|
|
@@ -170103,7 +169994,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
170103
169994
|
}
|
|
170104
169995
|
if (paths) {
|
|
170105
169996
|
const absolute = getPathsBasePath(compilerOptions, host);
|
|
170106
|
-
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, program, host, paths);
|
|
169997
|
+
addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, program, host, moduleSpecifierResolutionHost, paths);
|
|
170107
169998
|
}
|
|
170108
169999
|
const fragmentDirectory = getFragmentDirectory(fragment);
|
|
170109
170000
|
for (const ambientName of getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker)) {
|
|
@@ -170114,7 +170005,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
170114
170005
|
void 0
|
|
170115
170006
|
));
|
|
170116
170007
|
}
|
|
170117
|
-
getCompletionEntriesFromTypings(host,
|
|
170008
|
+
getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, fragmentDirectory, extensionOptions, result);
|
|
170118
170009
|
if (moduleResolutionUsesNodeModules(moduleResolution)) {
|
|
170119
170010
|
let foundGlobal = false;
|
|
170120
170011
|
if (fragmentDirectory === void 0) {
|
|
@@ -170132,6 +170023,26 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
170132
170023
|
}
|
|
170133
170024
|
}
|
|
170134
170025
|
if (!foundGlobal) {
|
|
170026
|
+
const resolvePackageJsonExports = getResolvePackageJsonExports(compilerOptions);
|
|
170027
|
+
const resolvePackageJsonImports = getResolvePackageJsonImports(compilerOptions);
|
|
170028
|
+
let seenPackageScope = false;
|
|
170029
|
+
const importsLookup = (directory) => {
|
|
170030
|
+
if (resolvePackageJsonImports && !seenPackageScope) {
|
|
170031
|
+
const packageFile = combinePaths(directory, "package.json");
|
|
170032
|
+
if (seenPackageScope = tryFileExists(host, packageFile)) {
|
|
170033
|
+
const packageJson = readJson(packageFile, host);
|
|
170034
|
+
exportsOrImportsLookup(
|
|
170035
|
+
packageJson.imports,
|
|
170036
|
+
fragment,
|
|
170037
|
+
directory,
|
|
170038
|
+
/*isExports*/
|
|
170039
|
+
false,
|
|
170040
|
+
/*isImports*/
|
|
170041
|
+
true
|
|
170042
|
+
);
|
|
170043
|
+
}
|
|
170044
|
+
}
|
|
170045
|
+
};
|
|
170135
170046
|
let ancestorLookup = (ancestor) => {
|
|
170136
170047
|
const nodeModules = combinePaths(ancestor, "node_modules");
|
|
170137
170048
|
if (tryDirectoryExists(host, nodeModules)) {
|
|
@@ -170141,6 +170052,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
170141
170052
|
extensionOptions,
|
|
170142
170053
|
program,
|
|
170143
170054
|
host,
|
|
170055
|
+
moduleSpecifierResolutionHost,
|
|
170144
170056
|
/*moduleSpecifierIsRelative*/
|
|
170145
170057
|
false,
|
|
170146
170058
|
/*exclude*/
|
|
@@ -170148,58 +170060,77 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, p
|
|
|
170148
170060
|
result
|
|
170149
170061
|
);
|
|
170150
170062
|
}
|
|
170063
|
+
importsLookup(ancestor);
|
|
170151
170064
|
};
|
|
170152
|
-
if (fragmentDirectory &&
|
|
170153
|
-
const
|
|
170065
|
+
if (fragmentDirectory && resolvePackageJsonExports) {
|
|
170066
|
+
const nodeModulesDirectoryOrImportsLookup = ancestorLookup;
|
|
170154
170067
|
ancestorLookup = (ancestor) => {
|
|
170155
170068
|
const components = getPathComponents(fragment);
|
|
170156
170069
|
components.shift();
|
|
170157
170070
|
let packagePath = components.shift();
|
|
170158
170071
|
if (!packagePath) {
|
|
170159
|
-
return
|
|
170072
|
+
return nodeModulesDirectoryOrImportsLookup(ancestor);
|
|
170160
170073
|
}
|
|
170161
170074
|
if (startsWith(packagePath, "@")) {
|
|
170162
170075
|
const subName = components.shift();
|
|
170163
170076
|
if (!subName) {
|
|
170164
|
-
return
|
|
170077
|
+
return nodeModulesDirectoryOrImportsLookup(ancestor);
|
|
170165
170078
|
}
|
|
170166
170079
|
packagePath = combinePaths(packagePath, subName);
|
|
170167
170080
|
}
|
|
170081
|
+
if (resolvePackageJsonImports && startsWith(packagePath, "#")) {
|
|
170082
|
+
return importsLookup(ancestor);
|
|
170083
|
+
}
|
|
170168
170084
|
const packageDirectory = combinePaths(ancestor, "node_modules", packagePath);
|
|
170169
170085
|
const packageFile = combinePaths(packageDirectory, "package.json");
|
|
170170
170086
|
if (tryFileExists(host, packageFile)) {
|
|
170171
170087
|
const packageJson = readJson(packageFile, host);
|
|
170172
|
-
const
|
|
170173
|
-
|
|
170174
|
-
|
|
170175
|
-
|
|
170176
|
-
|
|
170177
|
-
|
|
170178
|
-
|
|
170179
|
-
|
|
170180
|
-
|
|
170181
|
-
|
|
170182
|
-
|
|
170183
|
-
true,
|
|
170184
|
-
fragmentSubpath,
|
|
170185
|
-
packageDirectory,
|
|
170186
|
-
extensionOptions,
|
|
170187
|
-
program,
|
|
170188
|
-
host,
|
|
170189
|
-
keys,
|
|
170190
|
-
(key) => singleElementArray(getPatternFromFirstMatchingCondition(exports2[key], conditions)),
|
|
170191
|
-
comparePatternKeys
|
|
170192
|
-
);
|
|
170193
|
-
return;
|
|
170194
|
-
}
|
|
170088
|
+
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
|
170089
|
+
exportsOrImportsLookup(
|
|
170090
|
+
packageJson.exports,
|
|
170091
|
+
fragmentSubpath,
|
|
170092
|
+
packageDirectory,
|
|
170093
|
+
/*isExports*/
|
|
170094
|
+
true,
|
|
170095
|
+
/*isImports*/
|
|
170096
|
+
false
|
|
170097
|
+
);
|
|
170098
|
+
return;
|
|
170195
170099
|
}
|
|
170196
|
-
return
|
|
170100
|
+
return nodeModulesDirectoryOrImportsLookup(ancestor);
|
|
170197
170101
|
};
|
|
170198
170102
|
}
|
|
170199
170103
|
forEachAncestorDirectoryStoppingAtGlobalCache(host, scriptPath, ancestorLookup);
|
|
170200
170104
|
}
|
|
170201
170105
|
}
|
|
170202
170106
|
return arrayFrom(result.values());
|
|
170107
|
+
function exportsOrImportsLookup(lookupTable, fragment2, baseDirectory, isExports, isImports) {
|
|
170108
|
+
if (typeof lookupTable !== "object" || lookupTable === null) {
|
|
170109
|
+
return;
|
|
170110
|
+
}
|
|
170111
|
+
const keys = getOwnKeys(lookupTable);
|
|
170112
|
+
const conditions = getConditions(compilerOptions, mode);
|
|
170113
|
+
addCompletionEntriesFromPathsOrExportsOrImports(
|
|
170114
|
+
result,
|
|
170115
|
+
isExports,
|
|
170116
|
+
isImports,
|
|
170117
|
+
fragment2,
|
|
170118
|
+
baseDirectory,
|
|
170119
|
+
extensionOptions,
|
|
170120
|
+
program,
|
|
170121
|
+
host,
|
|
170122
|
+
moduleSpecifierResolutionHost,
|
|
170123
|
+
keys,
|
|
170124
|
+
(key) => {
|
|
170125
|
+
const pattern = getPatternFromFirstMatchingCondition(lookupTable[key], conditions);
|
|
170126
|
+
if (pattern === void 0) {
|
|
170127
|
+
return void 0;
|
|
170128
|
+
}
|
|
170129
|
+
return singleElementArray(endsWith(key, "/") && endsWith(pattern, "/") ? pattern + "*" : pattern);
|
|
170130
|
+
},
|
|
170131
|
+
comparePatternKeys
|
|
170132
|
+
);
|
|
170133
|
+
}
|
|
170203
170134
|
}
|
|
170204
170135
|
function getPatternFromFirstMatchingCondition(target, conditions) {
|
|
170205
170136
|
if (typeof target === "string") {
|
|
@@ -170217,25 +170148,28 @@ function getPatternFromFirstMatchingCondition(target, conditions) {
|
|
|
170217
170148
|
function getFragmentDirectory(fragment) {
|
|
170218
170149
|
return containsSlash(fragment) ? hasTrailingDirectorySeparator(fragment) ? fragment : getDirectoryPath(fragment) : void 0;
|
|
170219
170150
|
}
|
|
170220
|
-
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions,
|
|
170221
|
-
|
|
170222
|
-
|
|
170151
|
+
function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost) {
|
|
170152
|
+
const parsedPath = tryParsePattern(path);
|
|
170153
|
+
if (!parsedPath) {
|
|
170154
|
+
return emptyArray;
|
|
170155
|
+
}
|
|
170156
|
+
if (typeof parsedPath === "string") {
|
|
170157
|
+
return justPathMappingName(path, "script" /* scriptElement */);
|
|
170223
170158
|
}
|
|
170224
|
-
const
|
|
170225
|
-
const remainingFragment = tryRemovePrefix(fragment, pathPrefix);
|
|
170159
|
+
const remainingFragment = tryRemovePrefix(fragment, parsedPath.prefix);
|
|
170226
170160
|
if (remainingFragment === void 0) {
|
|
170227
|
-
const starIsFullPathComponent = path
|
|
170228
|
-
return starIsFullPathComponent ? justPathMappingName(
|
|
170161
|
+
const starIsFullPathComponent = endsWith(path, "/*");
|
|
170162
|
+
return starIsFullPathComponent ? justPathMappingName(parsedPath.prefix, "directory" /* directory */) : flatMap(patterns, (pattern) => {
|
|
170229
170163
|
var _a;
|
|
170230
|
-
return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions,
|
|
170164
|
+
return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost)) == null ? void 0 : _a.map(({ name, ...rest }) => ({ name: parsedPath.prefix + name + parsedPath.suffix, ...rest }));
|
|
170231
170165
|
});
|
|
170232
170166
|
}
|
|
170233
|
-
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions,
|
|
170167
|
+
return flatMap(patterns, (pattern) => getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost));
|
|
170234
170168
|
function justPathMappingName(name, kind) {
|
|
170235
170169
|
return startsWith(name, fragment) ? [{ name: removeTrailingDirectorySeparator(name), kind, extension: void 0 }] : emptyArray;
|
|
170236
170170
|
}
|
|
170237
170171
|
}
|
|
170238
|
-
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions,
|
|
170172
|
+
function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, isExports, isImports, program, host, moduleSpecifierResolutionHost) {
|
|
170239
170173
|
if (!host.readDirectory) {
|
|
170240
170174
|
return void 0;
|
|
170241
170175
|
}
|
|
@@ -170248,35 +170182,67 @@ function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensio
|
|
|
170248
170182
|
const normalizedPrefixBase = hasTrailingDirectorySeparator(parsed.prefix) ? "" : getBaseFileName(normalizedPrefix);
|
|
170249
170183
|
const fragmentHasPath = containsSlash(fragment);
|
|
170250
170184
|
const fragmentDirectory = fragmentHasPath ? hasTrailingDirectorySeparator(fragment) ? fragment : getDirectoryPath(fragment) : void 0;
|
|
170185
|
+
const getCommonSourceDirectory2 = () => moduleSpecifierResolutionHost.getCommonSourceDirectory();
|
|
170186
|
+
const ignoreCase = !hostUsesCaseSensitiveFileNames(moduleSpecifierResolutionHost);
|
|
170187
|
+
const outDir = program.getCompilerOptions().outDir;
|
|
170188
|
+
const declarationDir = program.getCompilerOptions().declarationDir;
|
|
170251
170189
|
const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory;
|
|
170190
|
+
const baseDirectory = normalizePath(combinePaths(packageDirectory, expandedPrefixDirectory));
|
|
170191
|
+
const possibleInputBaseDirectoryForOutDir = isImports && outDir && getPossibleOriginalInputPathWithoutChangingExt(baseDirectory, ignoreCase, outDir, getCommonSourceDirectory2);
|
|
170192
|
+
const possibleInputBaseDirectoryForDeclarationDir = isImports && declarationDir && getPossibleOriginalInputPathWithoutChangingExt(baseDirectory, ignoreCase, declarationDir, getCommonSourceDirectory2);
|
|
170252
170193
|
const normalizedSuffix = normalizePath(parsed.suffix);
|
|
170253
170194
|
const declarationExtension = normalizedSuffix && getDeclarationEmitExtensionForPath("_" + normalizedSuffix);
|
|
170254
|
-
const
|
|
170255
|
-
const
|
|
170256
|
-
|
|
170195
|
+
const inputExtension = normalizedSuffix ? getPossibleOriginalInputExtensionForExtension("_" + normalizedSuffix) : void 0;
|
|
170196
|
+
const matchingSuffixes = [
|
|
170197
|
+
declarationExtension && changeExtension(normalizedSuffix, declarationExtension),
|
|
170198
|
+
...inputExtension ? inputExtension.map((ext) => changeExtension(normalizedSuffix, ext)) : [],
|
|
170199
|
+
normalizedSuffix
|
|
170200
|
+
].filter(isString);
|
|
170257
170201
|
const includeGlobs = normalizedSuffix ? matchingSuffixes.map((suffix) => "**/*" + suffix) : ["./*"];
|
|
170258
|
-
const
|
|
170259
|
-
|
|
170260
|
-
|
|
170261
|
-
|
|
170262
|
-
|
|
170263
|
-
|
|
170264
|
-
|
|
170265
|
-
|
|
170266
|
-
|
|
170267
|
-
|
|
170268
|
-
|
|
170269
|
-
|
|
170270
|
-
}
|
|
170271
|
-
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, program, extensionOptions, isExportsWildcard);
|
|
170272
|
-
return nameAndKind(name, "script" /* scriptElement */, extension);
|
|
170202
|
+
const isExportsOrImportsWildcard = (isExports || isImports) && endsWith(pattern, "/*");
|
|
170203
|
+
let matches = getMatchesWithPrefix(baseDirectory);
|
|
170204
|
+
if (possibleInputBaseDirectoryForOutDir) {
|
|
170205
|
+
matches = concatenate(matches, getMatchesWithPrefix(possibleInputBaseDirectoryForOutDir));
|
|
170206
|
+
}
|
|
170207
|
+
if (possibleInputBaseDirectoryForDeclarationDir) {
|
|
170208
|
+
matches = concatenate(matches, getMatchesWithPrefix(possibleInputBaseDirectoryForDeclarationDir));
|
|
170209
|
+
}
|
|
170210
|
+
if (!normalizedSuffix) {
|
|
170211
|
+
matches = concatenate(matches, getDirectoryMatches(baseDirectory));
|
|
170212
|
+
if (possibleInputBaseDirectoryForOutDir) {
|
|
170213
|
+
matches = concatenate(matches, getDirectoryMatches(possibleInputBaseDirectoryForOutDir));
|
|
170273
170214
|
}
|
|
170274
|
-
|
|
170275
|
-
|
|
170276
|
-
|
|
170277
|
-
|
|
170215
|
+
if (possibleInputBaseDirectoryForDeclarationDir) {
|
|
170216
|
+
matches = concatenate(matches, getDirectoryMatches(possibleInputBaseDirectoryForDeclarationDir));
|
|
170217
|
+
}
|
|
170218
|
+
}
|
|
170219
|
+
return matches;
|
|
170220
|
+
function getMatchesWithPrefix(directory) {
|
|
170221
|
+
const completePrefix = fragmentHasPath ? directory : ensureTrailingDirectorySeparator(directory) + normalizedPrefixBase;
|
|
170222
|
+
return mapDefined(tryReadDirectory(
|
|
170223
|
+
host,
|
|
170224
|
+
directory,
|
|
170225
|
+
extensionOptions.extensionsToSearch,
|
|
170226
|
+
/*exclude*/
|
|
170227
|
+
void 0,
|
|
170228
|
+
includeGlobs
|
|
170229
|
+
), (match) => {
|
|
170230
|
+
const trimmedWithPattern = trimPrefixAndSuffix(match, completePrefix);
|
|
170231
|
+
if (trimmedWithPattern) {
|
|
170232
|
+
if (containsSlash(trimmedWithPattern)) {
|
|
170233
|
+
return directoryResult(getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]);
|
|
170234
|
+
}
|
|
170235
|
+
const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, program, extensionOptions, isExportsOrImportsWildcard);
|
|
170236
|
+
return nameAndKind(name, "script" /* scriptElement */, extension);
|
|
170237
|
+
}
|
|
170238
|
+
});
|
|
170239
|
+
}
|
|
170240
|
+
function getDirectoryMatches(directoryName) {
|
|
170241
|
+
return mapDefined(tryGetDirectories(host, directoryName), (dir) => dir === "node_modules" ? void 0 : directoryResult(dir));
|
|
170242
|
+
}
|
|
170243
|
+
function trimPrefixAndSuffix(path, prefix) {
|
|
170278
170244
|
return firstDefined(matchingSuffixes, (suffix) => {
|
|
170279
|
-
const inner = withoutStartAndEnd(normalizePath(path),
|
|
170245
|
+
const inner = withoutStartAndEnd(normalizePath(path), prefix, suffix);
|
|
170280
170246
|
return inner === void 0 ? void 0 : removeLeadingDirectorySeparator(inner);
|
|
170281
170247
|
});
|
|
170282
170248
|
}
|
|
@@ -170296,7 +170262,7 @@ function getAmbientModuleCompletions(fragment, fragmentDirectory, checker) {
|
|
|
170296
170262
|
}
|
|
170297
170263
|
return nonRelativeModuleNames;
|
|
170298
170264
|
}
|
|
170299
|
-
function getTripleSlashReferenceCompletion(sourceFile, position, program, host) {
|
|
170265
|
+
function getTripleSlashReferenceCompletion(sourceFile, position, program, host, moduleSpecifierResolutionHost) {
|
|
170300
170266
|
const compilerOptions = program.getCompilerOptions();
|
|
170301
170267
|
const token = getTokenAtPosition(sourceFile, position);
|
|
170302
170268
|
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
|
@@ -170317,13 +170283,14 @@ function getTripleSlashReferenceCompletion(sourceFile, position, program, host)
|
|
|
170317
170283
|
getExtensionOptions(compilerOptions, 0 /* Filename */, sourceFile),
|
|
170318
170284
|
program,
|
|
170319
170285
|
host,
|
|
170286
|
+
moduleSpecifierResolutionHost,
|
|
170320
170287
|
/*moduleSpecifierIsRelative*/
|
|
170321
170288
|
true,
|
|
170322
170289
|
sourceFile.path
|
|
170323
|
-
) : kind === "types" ? getCompletionEntriesFromTypings(host,
|
|
170290
|
+
) : kind === "types" ? getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile)) : Debug.fail();
|
|
170324
170291
|
return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values()));
|
|
170325
170292
|
}
|
|
170326
|
-
function getCompletionEntriesFromTypings(host,
|
|
170293
|
+
function getCompletionEntriesFromTypings(program, host, moduleSpecifierResolutionHost, scriptPath, fragmentDirectory, extensionOptions, result = createNameAndKindSet()) {
|
|
170327
170294
|
const options = program.getCompilerOptions();
|
|
170328
170295
|
const seen = /* @__PURE__ */ new Map();
|
|
170329
170296
|
const typeRoots = tryAndIgnoreErrors(() => getEffectiveTypeRoots(options, host)) || emptyArray;
|
|
@@ -170360,6 +170327,7 @@ function getCompletionEntriesFromTypings(host, program, scriptPath, fragmentDire
|
|
|
170360
170327
|
extensionOptions,
|
|
170361
170328
|
program,
|
|
170362
170329
|
host,
|
|
170330
|
+
moduleSpecifierResolutionHost,
|
|
170363
170331
|
/*moduleSpecifierIsRelative*/
|
|
170364
170332
|
false,
|
|
170365
170333
|
/*exclude*/
|
|
@@ -171112,7 +171080,7 @@ function getImplementationsAtPosition(program, cancellationToken, sourceFiles, s
|
|
|
171112
171080
|
referenceEntries = entries && [...entries];
|
|
171113
171081
|
} else if (entries) {
|
|
171114
171082
|
const queue = createQueue(entries);
|
|
171115
|
-
const seenNodes = /* @__PURE__ */ new
|
|
171083
|
+
const seenNodes = /* @__PURE__ */ new Set();
|
|
171116
171084
|
while (!queue.isEmpty()) {
|
|
171117
171085
|
const entry = queue.dequeue();
|
|
171118
171086
|
if (!addToSeen(seenNodes, getNodeId(entry.node))) {
|
|
@@ -172764,10 +172732,10 @@ var Core;
|
|
|
172764
172732
|
}
|
|
172765
172733
|
}
|
|
172766
172734
|
function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) {
|
|
172767
|
-
const seen = /* @__PURE__ */ new
|
|
172735
|
+
const seen = /* @__PURE__ */ new Set();
|
|
172768
172736
|
return recur(symbol);
|
|
172769
172737
|
function recur(symbol2) {
|
|
172770
|
-
if (!(symbol2.flags & (32 /* Class */ | 64 /* Interface */)) || !addToSeen(seen,
|
|
172738
|
+
if (!(symbol2.flags & (32 /* Class */ | 64 /* Interface */)) || !addToSeen(seen, symbol2)) return;
|
|
172771
172739
|
return firstDefined(symbol2.declarations, (declaration) => firstDefined(getAllSuperTypeNodes(declaration), (typeReference) => {
|
|
172772
172740
|
const type = checker.getTypeAtLocation(typeReference);
|
|
172773
172741
|
const propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName);
|
|
@@ -173553,11 +173521,8 @@ function provideInlayHints(context) {
|
|
|
173553
173521
|
if (!args || !args.length) {
|
|
173554
173522
|
return;
|
|
173555
173523
|
}
|
|
173556
|
-
const
|
|
173557
|
-
|
|
173558
|
-
if (!signature || !candidates.length) {
|
|
173559
|
-
return;
|
|
173560
|
-
}
|
|
173524
|
+
const signature = checker.getResolvedSignature(expr);
|
|
173525
|
+
if (signature === void 0) return;
|
|
173561
173526
|
let signatureParamPos = 0;
|
|
173562
173527
|
for (const originalArg of args) {
|
|
173563
173528
|
const arg = skipParentheses(originalArg);
|
|
@@ -177415,6 +177380,7 @@ __export(ts_textChanges_exports, {
|
|
|
177415
177380
|
assignPositionsToNode: () => assignPositionsToNode,
|
|
177416
177381
|
createWriter: () => createWriter,
|
|
177417
177382
|
deleteNode: () => deleteNode,
|
|
177383
|
+
getAdjustedEndPosition: () => getAdjustedEndPosition,
|
|
177418
177384
|
isThisTypeAnnotatable: () => isThisTypeAnnotatable,
|
|
177419
177385
|
isValidLocationToAddComment: () => isValidLocationToAddComment
|
|
177420
177386
|
});
|
|
@@ -177914,7 +177880,10 @@ var ChangeTracker = class _ChangeTracker {
|
|
|
177914
177880
|
getInsertNodeAtStartInsertOptions(sourceFile, node, indentation) {
|
|
177915
177881
|
const members = getMembersOrProperties(node);
|
|
177916
177882
|
const isEmpty = members.length === 0;
|
|
177917
|
-
const isFirstInsertion =
|
|
177883
|
+
const isFirstInsertion = !this.classesWithNodesInsertedAtStart.has(getNodeId(node));
|
|
177884
|
+
if (isFirstInsertion) {
|
|
177885
|
+
this.classesWithNodesInsertedAtStart.set(getNodeId(node), { node, sourceFile });
|
|
177886
|
+
}
|
|
177918
177887
|
const insertTrailingComma = isObjectLiteralExpression(node) && (!isJsonSourceFile(sourceFile) || !isEmpty);
|
|
177919
177888
|
const insertLeadingComma = isObjectLiteralExpression(node) && isJsonSourceFile(sourceFile) && isEmpty && !isFirstInsertion;
|
|
177920
177889
|
return {
|
|
@@ -179824,6 +179793,9 @@ function isSemicolonDeletionContext(context) {
|
|
|
179824
179793
|
if (startLine === endLine) {
|
|
179825
179794
|
return nextTokenKind === 20 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */;
|
|
179826
179795
|
}
|
|
179796
|
+
if (nextTokenKind === 27 /* SemicolonToken */ && context.currentTokenSpan.kind === 27 /* SemicolonToken */) {
|
|
179797
|
+
return true;
|
|
179798
|
+
}
|
|
179827
179799
|
if (nextTokenKind === 240 /* SemicolonClassElement */ || nextTokenKind === 27 /* SemicolonToken */) {
|
|
179828
179800
|
return false;
|
|
179829
179801
|
}
|
|
@@ -181569,11 +181541,13 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
|
|
|
181569
181541
|
}
|
|
181570
181542
|
statements.push(...statementsInSourceFile.slice(startNodeIndex, endNodeIndex === -1 ? statementsInSourceFile.length : endNodeIndex + 1));
|
|
181571
181543
|
});
|
|
181572
|
-
|
|
181573
|
-
|
|
181544
|
+
Debug.assertIsDefined(originalProgram, "no original program found");
|
|
181545
|
+
const originalProgramTypeChecker = originalProgram.getTypeChecker();
|
|
181546
|
+
const usageInfoRange = getUsageInfoRangeForPasteEdits(copiedFrom);
|
|
181547
|
+
const usage = getUsageInfo(copiedFrom.file, statements, originalProgramTypeChecker, getExistingLocals(updatedFile, statements, originalProgramTypeChecker), usageInfoRange);
|
|
181574
181548
|
const useEsModuleSyntax = !fileShouldUseJavaScriptRequire(targetFile.fileName, originalProgram, host, !!copiedFrom.file.commonJsModuleIndicator);
|
|
181575
181549
|
addExportsInOldFile(copiedFrom.file, usage.targetFileImportsFromOldFile, changes, useEsModuleSyntax);
|
|
181576
|
-
addTargetFileImports(copiedFrom.file, usage.oldImportsNeededByTargetFile, usage.targetFileImportsFromOldFile,
|
|
181550
|
+
addTargetFileImports(copiedFrom.file, usage.oldImportsNeededByTargetFile, usage.targetFileImportsFromOldFile, originalProgramTypeChecker, updatedProgram, importAdder);
|
|
181577
181551
|
} else {
|
|
181578
181552
|
const context = {
|
|
181579
181553
|
sourceFile: updatedFile,
|
|
@@ -181629,6 +181603,16 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
|
|
|
181629
181603
|
);
|
|
181630
181604
|
});
|
|
181631
181605
|
}
|
|
181606
|
+
function getUsageInfoRangeForPasteEdits({ file: sourceFile, range }) {
|
|
181607
|
+
const pos = range[0].pos;
|
|
181608
|
+
const end = range[range.length - 1].end;
|
|
181609
|
+
const startToken = getTokenAtPosition(sourceFile, pos);
|
|
181610
|
+
const endToken = findTokenOnLeftOfPosition(sourceFile, pos) ?? getTokenAtPosition(sourceFile, end);
|
|
181611
|
+
return {
|
|
181612
|
+
pos: isIdentifier(startToken) && pos <= startToken.getStart(sourceFile) ? startToken.getFullStart() : pos,
|
|
181613
|
+
end: isIdentifier(endToken) && end === endToken.getEnd() ? ts_textChanges_exports.getAdjustedEndPosition(sourceFile, endToken, {}) : end
|
|
181614
|
+
};
|
|
181615
|
+
}
|
|
181632
181616
|
|
|
181633
181617
|
// src/server/_namespaces/ts.ts
|
|
181634
181618
|
var ts_exports2 = {};
|
|
@@ -182542,6 +182526,7 @@ __export(ts_exports2, {
|
|
|
182542
182526
|
getPositionOfLineAndCharacter: () => getPositionOfLineAndCharacter,
|
|
182543
182527
|
getPossibleGenericSignatures: () => getPossibleGenericSignatures,
|
|
182544
182528
|
getPossibleOriginalInputExtensionForExtension: () => getPossibleOriginalInputExtensionForExtension,
|
|
182529
|
+
getPossibleOriginalInputPathWithoutChangingExt: () => getPossibleOriginalInputPathWithoutChangingExt,
|
|
182545
182530
|
getPossibleTypeArgumentsInfo: () => getPossibleTypeArgumentsInfo,
|
|
182546
182531
|
getPreEmitDiagnostics: () => getPreEmitDiagnostics,
|
|
182547
182532
|
getPrecedingNonSpaceCharacterPosition: () => getPrecedingNonSpaceCharacterPosition,
|
|
@@ -188300,7 +188285,7 @@ var _ProjectService = class _ProjectService {
|
|
|
188300
188285
|
*/
|
|
188301
188286
|
this.filenameToScriptInfoVersion = /* @__PURE__ */ new Map();
|
|
188302
188287
|
// Set of all '.js' files ever opened.
|
|
188303
|
-
this.allJsFilesForOpenFileTelemetry = /* @__PURE__ */ new
|
|
188288
|
+
this.allJsFilesForOpenFileTelemetry = /* @__PURE__ */ new Set();
|
|
188304
188289
|
/**
|
|
188305
188290
|
* maps external project file name to list of config files that were the part of this project
|
|
188306
188291
|
*/
|
|
@@ -195882,6 +195867,7 @@ var LineNode = class _LineNode {
|
|
|
195882
195867
|
}
|
|
195883
195868
|
}
|
|
195884
195869
|
walk(rangeStart, rangeLength, walkFns) {
|
|
195870
|
+
if (this.children.length === 0) return;
|
|
195885
195871
|
let childIndex = 0;
|
|
195886
195872
|
let childCharCount = this.children[childIndex].charCount();
|
|
195887
195873
|
let adjustedStart = rangeStart;
|
|
@@ -197286,6 +197272,7 @@ if (typeof console !== "undefined") {
|
|
|
197286
197272
|
getPositionOfLineAndCharacter,
|
|
197287
197273
|
getPossibleGenericSignatures,
|
|
197288
197274
|
getPossibleOriginalInputExtensionForExtension,
|
|
197275
|
+
getPossibleOriginalInputPathWithoutChangingExt,
|
|
197289
197276
|
getPossibleTypeArgumentsInfo,
|
|
197290
197277
|
getPreEmitDiagnostics,
|
|
197291
197278
|
getPrecedingNonSpaceCharacterPosition,
|