typescript 5.3.0-dev.20230919 → 5.3.0-dev.20230921
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/lib.dom.d.ts +4 -0
- package/lib/lib.webworker.d.ts +2 -0
- package/lib/tsc.js +114 -132
- package/lib/tsserver.js +489 -204
- package/lib/typescript.js +490 -200
- package/lib/typingsInstaller.js +17 -6
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -994,8 +994,6 @@ __export(server_exports, {
|
|
|
994
994
|
getResolvePackageJsonExports: () => getResolvePackageJsonExports,
|
|
995
995
|
getResolvePackageJsonImports: () => getResolvePackageJsonImports,
|
|
996
996
|
getResolvedExternalModuleName: () => getResolvedExternalModuleName,
|
|
997
|
-
getResolvedModule: () => getResolvedModule,
|
|
998
|
-
getResolvedTypeReferenceDirective: () => getResolvedTypeReferenceDirective,
|
|
999
997
|
getRestIndicatorOfBindingOrAssignmentElement: () => getRestIndicatorOfBindingOrAssignmentElement,
|
|
1000
998
|
getRestParameterElementType: () => getRestParameterElementType,
|
|
1001
999
|
getRightMostAssignedExpression: () => getRightMostAssignedExpression,
|
|
@@ -2093,8 +2091,6 @@ __export(server_exports, {
|
|
|
2093
2091
|
setParent: () => setParent,
|
|
2094
2092
|
setParentRecursive: () => setParentRecursive,
|
|
2095
2093
|
setPrivateIdentifier: () => setPrivateIdentifier,
|
|
2096
|
-
setResolvedModule: () => setResolvedModule,
|
|
2097
|
-
setResolvedTypeReferenceDirective: () => setResolvedTypeReferenceDirective,
|
|
2098
2094
|
setSnippetElement: () => setSnippetElement,
|
|
2099
2095
|
setSourceMapRange: () => setSourceMapRange,
|
|
2100
2096
|
setStackTraceLimit: () => setStackTraceLimit,
|
|
@@ -2321,14 +2317,13 @@ __export(server_exports, {
|
|
|
2321
2317
|
writeCommentRange: () => writeCommentRange,
|
|
2322
2318
|
writeFile: () => writeFile,
|
|
2323
2319
|
writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
|
|
2324
|
-
zipToModeAwareCache: () => zipToModeAwareCache,
|
|
2325
2320
|
zipWith: () => zipWith
|
|
2326
2321
|
});
|
|
2327
2322
|
module.exports = __toCommonJS(server_exports);
|
|
2328
2323
|
|
|
2329
2324
|
// src/compiler/corePublic.ts
|
|
2330
2325
|
var versionMajorMinor = "5.3";
|
|
2331
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2326
|
+
var version = `${versionMajorMinor}.0-dev.20230921`;
|
|
2332
2327
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2333
2328
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2334
2329
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -15143,26 +15138,6 @@ function usingSingleLineStringWriter(action) {
|
|
|
15143
15138
|
function getFullWidth(node) {
|
|
15144
15139
|
return node.end - node.pos;
|
|
15145
15140
|
}
|
|
15146
|
-
function getResolvedModule(sourceFile, moduleNameText, mode) {
|
|
15147
|
-
var _a, _b;
|
|
15148
|
-
return (_b = (_a = sourceFile == null ? void 0 : sourceFile.resolvedModules) == null ? void 0 : _a.get(moduleNameText, mode)) == null ? void 0 : _b.resolvedModule;
|
|
15149
|
-
}
|
|
15150
|
-
function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
|
|
15151
|
-
if (!sourceFile.resolvedModules) {
|
|
15152
|
-
sourceFile.resolvedModules = createModeAwareCache();
|
|
15153
|
-
}
|
|
15154
|
-
sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
|
|
15155
|
-
}
|
|
15156
|
-
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
|
|
15157
|
-
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
15158
|
-
sourceFile.resolvedTypeReferenceDirectiveNames = createModeAwareCache();
|
|
15159
|
-
}
|
|
15160
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
|
|
15161
|
-
}
|
|
15162
|
-
function getResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, mode) {
|
|
15163
|
-
var _a, _b;
|
|
15164
|
-
return (_b = (_a = sourceFile == null ? void 0 : sourceFile.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _a.get(typeReferenceDirectiveName, mode)) == null ? void 0 : _b.resolvedTypeReferenceDirective;
|
|
15165
|
-
}
|
|
15166
15141
|
function projectReferenceIsEqualTo(oldRef, newRef) {
|
|
15167
15142
|
return oldRef.path === newRef.path && !oldRef.prepend === !newRef.prepend && !oldRef.circular === !newRef.circular;
|
|
15168
15143
|
}
|
|
@@ -15170,8 +15145,8 @@ function moduleResolutionIsEqualTo(oldResolution, newResolution) {
|
|
|
15170
15145
|
return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId) && oldResolution.node10Result === newResolution.node10Result;
|
|
15171
15146
|
}
|
|
15172
15147
|
function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageName) {
|
|
15173
|
-
var _a, _b;
|
|
15174
|
-
const node10Result = (_b = (_a =
|
|
15148
|
+
var _a, _b, _c;
|
|
15149
|
+
const node10Result = (_c = (_b = (_a = host.resolvedModules) == null ? void 0 : _a.get(sourceFile.path)) == null ? void 0 : _b.get(moduleReference, mode)) == null ? void 0 : _c.node10Result;
|
|
15175
15150
|
const result = node10Result ? chainDiagnosticMessages(
|
|
15176
15151
|
/*details*/
|
|
15177
15152
|
void 0,
|
|
@@ -20572,7 +20547,7 @@ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
|
|
|
20572
20547
|
return optionsHaveChanges(oldOptions, newOptions, affectsDeclarationPathOptionDeclarations);
|
|
20573
20548
|
}
|
|
20574
20549
|
function getCompilerOptionValue(options, option) {
|
|
20575
|
-
return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
|
|
20550
|
+
return option.strictFlag ? getStrictOptionValue(options, option.name) : option.allowJsFlag ? getAllowJSCompilerOption(options) : options[option.name];
|
|
20576
20551
|
}
|
|
20577
20552
|
function getJSXTransformEnabled(options) {
|
|
20578
20553
|
const jsx = options.jsx;
|
|
@@ -20619,14 +20594,11 @@ function createSymlinkCache(cwd, getCanonicalFileName) {
|
|
|
20619
20594
|
(symlinkedDirectories || (symlinkedDirectories = /* @__PURE__ */ new Map())).set(symlinkPath, real);
|
|
20620
20595
|
}
|
|
20621
20596
|
},
|
|
20622
|
-
setSymlinksFromResolutions(
|
|
20623
|
-
var _a, _b;
|
|
20597
|
+
setSymlinksFromResolutions(resolvedModules, resolvedTypeReferenceDirectiveNames, typeReferenceDirectives) {
|
|
20624
20598
|
Debug.assert(!hasProcessedResolutions);
|
|
20625
20599
|
hasProcessedResolutions = true;
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
(_b = file.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _b.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
|
|
20629
|
-
}
|
|
20600
|
+
resolvedModules == null ? void 0 : resolvedModules.forEach((cache) => cache.forEach((resolution) => processResolution(this, resolution.resolvedModule)));
|
|
20601
|
+
resolvedTypeReferenceDirectiveNames == null ? void 0 : resolvedTypeReferenceDirectiveNames.forEach((cache) => cache.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective)));
|
|
20630
20602
|
typeReferenceDirectives.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
|
|
20631
20603
|
},
|
|
20632
20604
|
hasProcessedResolutions: () => hasProcessedResolutions
|
|
@@ -25666,7 +25638,6 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
25666
25638
|
node.imports = void 0;
|
|
25667
25639
|
node.moduleAugmentations = void 0;
|
|
25668
25640
|
node.ambientModuleNames = void 0;
|
|
25669
|
-
node.resolvedModules = void 0;
|
|
25670
25641
|
node.classifiableNames = void 0;
|
|
25671
25642
|
node.impliedNodeFormat = void 0;
|
|
25672
25643
|
return node;
|
|
@@ -38485,6 +38456,7 @@ var moduleOptionDeclaration = {
|
|
|
38485
38456
|
node16: 100 /* Node16 */,
|
|
38486
38457
|
nodenext: 199 /* NodeNext */
|
|
38487
38458
|
})),
|
|
38459
|
+
affectsSourceFile: true,
|
|
38488
38460
|
affectsModuleResolution: true,
|
|
38489
38461
|
affectsEmit: true,
|
|
38490
38462
|
affectsBuildInfo: true,
|
|
@@ -38577,7 +38549,8 @@ var commandOptionsWithoutBuild = [
|
|
|
38577
38549
|
{
|
|
38578
38550
|
name: "allowJs",
|
|
38579
38551
|
type: "boolean",
|
|
38580
|
-
|
|
38552
|
+
allowJsFlag: true,
|
|
38553
|
+
affectsBuildInfo: true,
|
|
38581
38554
|
showInSimplifiedHelpView: true,
|
|
38582
38555
|
category: Diagnostics.JavaScript_Support,
|
|
38583
38556
|
description: Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files,
|
|
@@ -38587,6 +38560,8 @@ var commandOptionsWithoutBuild = [
|
|
|
38587
38560
|
name: "checkJs",
|
|
38588
38561
|
type: "boolean",
|
|
38589
38562
|
affectsModuleResolution: true,
|
|
38563
|
+
affectsSemanticDiagnostics: true,
|
|
38564
|
+
affectsBuildInfo: true,
|
|
38590
38565
|
showInSimplifiedHelpView: true,
|
|
38591
38566
|
category: Diagnostics.JavaScript_Support,
|
|
38592
38567
|
description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files,
|
|
@@ -38599,6 +38574,10 @@ var commandOptionsWithoutBuild = [
|
|
|
38599
38574
|
affectsEmit: true,
|
|
38600
38575
|
affectsBuildInfo: true,
|
|
38601
38576
|
affectsModuleResolution: true,
|
|
38577
|
+
// The checker emits an error when it sees JSX but this option is not set in compilerOptions.
|
|
38578
|
+
// This is effectively a semantic error, so mark this option as affecting semantic diagnostics
|
|
38579
|
+
// so we know to refresh errors when this option is changed.
|
|
38580
|
+
affectsSemanticDiagnostics: true,
|
|
38602
38581
|
paramType: Diagnostics.KIND,
|
|
38603
38582
|
showInSimplifiedHelpView: true,
|
|
38604
38583
|
category: Diagnostics.Language_and_Environment,
|
|
@@ -38914,6 +38893,7 @@ var commandOptionsWithoutBuild = [
|
|
|
38914
38893
|
bundler: 100 /* Bundler */
|
|
38915
38894
|
})),
|
|
38916
38895
|
deprecatedKeys: /* @__PURE__ */ new Set(["node"]),
|
|
38896
|
+
affectsSourceFile: true,
|
|
38917
38897
|
affectsModuleResolution: true,
|
|
38918
38898
|
paramType: Diagnostics.STRATEGY,
|
|
38919
38899
|
category: Diagnostics.Modules,
|
|
@@ -39456,6 +39436,7 @@ var commandOptionsWithoutBuild = [
|
|
|
39456
39436
|
legacy: 1 /* Legacy */,
|
|
39457
39437
|
force: 3 /* Force */
|
|
39458
39438
|
})),
|
|
39439
|
+
affectsSourceFile: true,
|
|
39459
39440
|
affectsModuleResolution: true,
|
|
39460
39441
|
description: Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
|
|
39461
39442
|
category: Diagnostics.Language_and_Environment,
|
|
@@ -39475,7 +39456,7 @@ var semanticDiagnosticsOptionDeclarations = optionDeclarations.filter((option) =
|
|
|
39475
39456
|
var affectsEmitOptionDeclarations = optionDeclarations.filter((option) => !!option.affectsEmit);
|
|
39476
39457
|
var affectsDeclarationPathOptionDeclarations = optionDeclarations.filter((option) => !!option.affectsDeclarationPath);
|
|
39477
39458
|
var moduleResolutionOptionDeclarations = optionDeclarations.filter((option) => !!option.affectsModuleResolution);
|
|
39478
|
-
var sourceFileAffectingCompilerOptions = optionDeclarations.filter((option) => !!option.affectsSourceFile || !!option.
|
|
39459
|
+
var sourceFileAffectingCompilerOptions = optionDeclarations.filter((option) => !!option.affectsSourceFile || !!option.affectsBindDiagnostics);
|
|
39479
39460
|
var optionsAffectingProgramStructure = optionDeclarations.filter((option) => !!option.affectsProgramStructure);
|
|
39480
39461
|
var transpileOptionValueCompilerOptions = optionDeclarations.filter((option) => hasProperty(option, "transpileOptionValue"));
|
|
39481
39462
|
var optionsForBuild = [
|
|
@@ -41950,15 +41931,6 @@ function createModeAwareCache() {
|
|
|
41950
41931
|
return result;
|
|
41951
41932
|
}
|
|
41952
41933
|
}
|
|
41953
|
-
function zipToModeAwareCache(file, keys, values, nameAndModeGetter) {
|
|
41954
|
-
Debug.assert(keys.length === values.length);
|
|
41955
|
-
const map2 = createModeAwareCache();
|
|
41956
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
41957
|
-
const entry = keys[i];
|
|
41958
|
-
map2.set(nameAndModeGetter.getName(entry), nameAndModeGetter.getMode(entry, file), values[i]);
|
|
41959
|
-
}
|
|
41960
|
-
return map2;
|
|
41961
|
-
}
|
|
41962
41934
|
function getOriginalOrResolvedModuleFileName(result) {
|
|
41963
41935
|
return result.resolvedModule && (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
|
|
41964
41936
|
}
|
|
@@ -44577,7 +44549,7 @@ function createBinder() {
|
|
|
44577
44549
|
case 36 /* ExclamationEqualsToken */:
|
|
44578
44550
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
44579
44551
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
44580
|
-
return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
|
|
44552
|
+
return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) || (isBooleanLiteral(expr.right) && isNarrowingExpression(expr.left) || isBooleanLiteral(expr.left) && isNarrowingExpression(expr.right));
|
|
44581
44553
|
case 104 /* InstanceOfKeyword */:
|
|
44582
44554
|
return isNarrowableOperand(expr.left);
|
|
44583
44555
|
case 103 /* InKeyword */:
|
|
@@ -51006,7 +50978,7 @@ function createTypeChecker(host) {
|
|
|
51006
50978
|
return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) : void 0;
|
|
51007
50979
|
}
|
|
51008
50980
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
|
|
51009
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
50981
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
51010
50982
|
if (startsWith(moduleReference, "@types/")) {
|
|
51011
50983
|
const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
51012
50984
|
const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
|
|
@@ -51024,7 +50996,7 @@ function createTypeChecker(host) {
|
|
|
51024
50996
|
const contextSpecifier = isStringLiteralLike(location) ? location : ((_a = findAncestor(location, isImportCall)) == null ? void 0 : _a.arguments[0]) || ((_b = findAncestor(location, isImportDeclaration)) == null ? void 0 : _b.moduleSpecifier) || ((_c = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _c.moduleReference.expression) || ((_d = findAncestor(location, isExportDeclaration)) == null ? void 0 : _d.moduleSpecifier) || ((_e = isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : void 0) == null ? void 0 : _e.name) || ((_f = isLiteralImportTypeNode(location) ? location : void 0) == null ? void 0 : _f.argument.literal);
|
|
51025
50997
|
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
51026
50998
|
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
51027
|
-
const resolvedModule =
|
|
50999
|
+
const resolvedModule = (_i = (_h = (_g = host.resolvedModules) == null ? void 0 : _g.get(currentSourceFile.path)) == null ? void 0 : _h.get(moduleReference, mode)) == null ? void 0 : _i.resolvedModule;
|
|
51028
51000
|
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
|
51029
51001
|
const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
51030
51002
|
if (sourceFile) {
|
|
@@ -51032,7 +51004,7 @@ function createTypeChecker(host) {
|
|
|
51032
51004
|
error2(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
|
|
51033
51005
|
}
|
|
51034
51006
|
if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) {
|
|
51035
|
-
const importOrExport = ((
|
|
51007
|
+
const importOrExport = ((_j = findAncestor(location, isImportDeclaration)) == null ? void 0 : _j.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
|
|
51036
51008
|
if (importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) {
|
|
51037
51009
|
error2(
|
|
51038
51010
|
errorNode,
|
|
@@ -51041,7 +51013,7 @@ function createTypeChecker(host) {
|
|
|
51041
51013
|
);
|
|
51042
51014
|
}
|
|
51043
51015
|
} else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
|
|
51044
|
-
const importOrExport = ((
|
|
51016
|
+
const importOrExport = ((_k = findAncestor(location, isImportDeclaration)) == null ? void 0 : _k.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
|
|
51045
51017
|
if (!((importOrExport == null ? void 0 : importOrExport.isTypeOnly) || findAncestor(location, isImportTypeNode))) {
|
|
51046
51018
|
const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
|
|
51047
51019
|
error2(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
|
|
@@ -51062,7 +51034,7 @@ function createTypeChecker(host) {
|
|
|
51062
51034
|
if (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */) {
|
|
51063
51035
|
const isSyncImport = currentSourceFile.impliedNodeFormat === 1 /* CommonJS */ && !findAncestor(location, isImportCall) || !!findAncestor(location, isImportEqualsDeclaration);
|
|
51064
51036
|
const overrideClauseHost = findAncestor(location, (l) => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l));
|
|
51065
|
-
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (
|
|
51037
|
+
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (_l = overrideClauseHost.assertions) == null ? void 0 : _l.assertClause : overrideClauseHost == null ? void 0 : overrideClauseHost.assertClause;
|
|
51066
51038
|
if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !getResolutionModeOverrideForClause(overrideClause)) {
|
|
51067
51039
|
if (findAncestor(location, isImportEqualsDeclaration)) {
|
|
51068
51040
|
error2(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference);
|
|
@@ -51169,7 +51141,7 @@ function createTypeChecker(host) {
|
|
|
51169
51141
|
error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
51170
51142
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
51171
51143
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
51172
|
-
const suggestedExt = (
|
|
51144
|
+
const suggestedExt = (_m = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _m[1];
|
|
51173
51145
|
if (suggestedExt) {
|
|
51174
51146
|
error2(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
|
|
51175
51147
|
} else {
|
|
@@ -58901,7 +58873,7 @@ function createTypeChecker(host) {
|
|
|
58901
58873
|
}
|
|
58902
58874
|
function isConstTypeVariable(type, depth = 0) {
|
|
58903
58875
|
var _a;
|
|
58904
|
-
return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags &
|
|
58876
|
+
return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
|
|
58905
58877
|
}
|
|
58906
58878
|
function getConstraintOfIndexedAccess(type) {
|
|
58907
58879
|
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
|
|
@@ -70507,6 +70479,10 @@ function createTypeChecker(host) {
|
|
|
70507
70479
|
}
|
|
70508
70480
|
return type;
|
|
70509
70481
|
}
|
|
70482
|
+
function narrowTypeByBooleanComparison(type, expr, bool, operator, assumeTrue) {
|
|
70483
|
+
assumeTrue = assumeTrue !== (bool.kind === 112 /* TrueKeyword */) !== (operator !== 38 /* ExclamationEqualsEqualsToken */ && operator !== 36 /* ExclamationEqualsToken */);
|
|
70484
|
+
return narrowType(type, expr, assumeTrue);
|
|
70485
|
+
}
|
|
70510
70486
|
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
|
|
70511
70487
|
switch (expr.operatorToken.kind) {
|
|
70512
70488
|
case 64 /* EqualsToken */:
|
|
@@ -70554,6 +70530,12 @@ function createTypeChecker(host) {
|
|
|
70554
70530
|
if (isMatchingConstructorReference(right)) {
|
|
70555
70531
|
return narrowTypeByConstructor(type, operator, left, assumeTrue);
|
|
70556
70532
|
}
|
|
70533
|
+
if (isBooleanLiteral(right)) {
|
|
70534
|
+
return narrowTypeByBooleanComparison(type, left, right, operator, assumeTrue);
|
|
70535
|
+
}
|
|
70536
|
+
if (isBooleanLiteral(left)) {
|
|
70537
|
+
return narrowTypeByBooleanComparison(type, right, left, operator, assumeTrue);
|
|
70538
|
+
}
|
|
70557
70539
|
break;
|
|
70558
70540
|
case 104 /* InstanceOfKeyword */:
|
|
70559
70541
|
return narrowTypeByInstanceof(type, expr, assumeTrue);
|
|
@@ -120310,15 +120292,15 @@ function isReferencedFile(reason) {
|
|
|
120310
120292
|
function isReferenceFileLocation(location) {
|
|
120311
120293
|
return location.pos !== void 0;
|
|
120312
120294
|
}
|
|
120313
|
-
function getReferencedFileLocation(
|
|
120314
|
-
var _a, _b, _c, _d, _e, _f;
|
|
120315
|
-
const file = Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
120295
|
+
function getReferencedFileLocation(program, ref) {
|
|
120296
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
120297
|
+
const file = Debug.checkDefined(program.getSourceFileByPath(ref.file));
|
|
120316
120298
|
const { kind, index } = ref;
|
|
120317
120299
|
let pos, end, packageId, resolutionMode;
|
|
120318
120300
|
switch (kind) {
|
|
120319
120301
|
case 3 /* Import */:
|
|
120320
120302
|
const importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
120321
|
-
packageId = (_c = (_b = (_a =
|
|
120303
|
+
packageId = (_d = (_c = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(file.path)) == null ? void 0 : _b.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) == null ? void 0 : _c.resolvedModule) == null ? void 0 : _d.packageId;
|
|
120322
120304
|
if (importLiteral.pos === -1)
|
|
120323
120305
|
return { file, packageId, text: importLiteral.text };
|
|
120324
120306
|
pos = skipTrivia(file.text, importLiteral.pos);
|
|
@@ -120329,7 +120311,7 @@ function getReferencedFileLocation(getSourceFileByPath, ref) {
|
|
|
120329
120311
|
break;
|
|
120330
120312
|
case 5 /* TypeReferenceDirective */:
|
|
120331
120313
|
({ pos, end, resolutionMode } = file.typeReferenceDirectives[index]);
|
|
120332
|
-
packageId = (
|
|
120314
|
+
packageId = (_h = (_g = (_f = (_e = program.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _e.get(file.path)) == null ? void 0 : _f.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) == null ? void 0 : _g.resolvedTypeReferenceDirective) == null ? void 0 : _h.packageId;
|
|
120333
120315
|
break;
|
|
120334
120316
|
case 7 /* LibReferenceDirective */:
|
|
120335
120317
|
({ pos, end } = file.libReferenceDirectives[index]);
|
|
@@ -120547,6 +120529,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120547
120529
|
let automaticTypeDirectiveResolutions;
|
|
120548
120530
|
let resolvedLibReferences;
|
|
120549
120531
|
let resolvedLibProcessing;
|
|
120532
|
+
let resolvedModules;
|
|
120533
|
+
let resolvedModulesProcessing;
|
|
120534
|
+
let resolvedTypeReferenceDirectiveNames;
|
|
120535
|
+
let resolvedTypeReferenceDirectiveNamesProcessing;
|
|
120550
120536
|
let packageMap;
|
|
120551
120537
|
const maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
|
|
120552
120538
|
let currentNodeModulesDepth = 0;
|
|
@@ -120811,6 +120797,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120811
120797
|
}
|
|
120812
120798
|
oldProgram = void 0;
|
|
120813
120799
|
resolvedLibProcessing = void 0;
|
|
120800
|
+
resolvedModulesProcessing = void 0;
|
|
120801
|
+
resolvedTypeReferenceDirectiveNamesProcessing = void 0;
|
|
120814
120802
|
const program = {
|
|
120815
120803
|
getRootFileNames: () => rootNames,
|
|
120816
120804
|
getSourceFile,
|
|
@@ -120852,6 +120840,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120852
120840
|
sourceFileToPackageName,
|
|
120853
120841
|
redirectTargetsMap,
|
|
120854
120842
|
usesUriStyleNodeCoreModules,
|
|
120843
|
+
resolvedModules,
|
|
120844
|
+
resolvedTypeReferenceDirectiveNames,
|
|
120855
120845
|
resolvedLibReferences,
|
|
120856
120846
|
getCurrentPackagesMap: () => packageMap,
|
|
120857
120847
|
typesPackageExists,
|
|
@@ -120883,7 +120873,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120883
120873
|
case 1 /* FilePreprocessingFileExplainingDiagnostic */:
|
|
120884
120874
|
return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || emptyArray));
|
|
120885
120875
|
case 0 /* FilePreprocessingReferencedDiagnostic */:
|
|
120886
|
-
const { file, pos, end } = getReferencedFileLocation(
|
|
120876
|
+
const { file, pos, end } = getReferencedFileLocation(program, diagnostic.reason);
|
|
120887
120877
|
return programDiagnostics.add(createFileDiagnostic(file, Debug.checkDefined(pos), Debug.checkDefined(end) - pos, diagnostic.diagnostic, ...diagnostic.args || emptyArray));
|
|
120888
120878
|
case 2 /* ResolutionDiagnostics */:
|
|
120889
120879
|
return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
|
|
@@ -120900,14 +120890,15 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120900
120890
|
if (packageMap)
|
|
120901
120891
|
return packageMap;
|
|
120902
120892
|
packageMap = /* @__PURE__ */ new Map();
|
|
120903
|
-
files.forEach(
|
|
120904
|
-
|
|
120905
|
-
|
|
120906
|
-
|
|
120907
|
-
|
|
120908
|
-
|
|
120909
|
-
|
|
120910
|
-
|
|
120893
|
+
files.forEach(
|
|
120894
|
+
(sf) => {
|
|
120895
|
+
var _a2;
|
|
120896
|
+
return (_a2 = resolvedModules == null ? void 0 : resolvedModules.get(sf.path)) == null ? void 0 : _a2.forEach(({ resolvedModule }) => {
|
|
120897
|
+
if (resolvedModule == null ? void 0 : resolvedModule.packageId)
|
|
120898
|
+
packageMap.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!packageMap.get(resolvedModule.packageId.name));
|
|
120899
|
+
});
|
|
120900
|
+
}
|
|
120901
|
+
);
|
|
120911
120902
|
return packageMap;
|
|
120912
120903
|
}
|
|
120913
120904
|
function typesPackageExists(packageName) {
|
|
@@ -121039,7 +121030,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121039
121030
|
return classifiableNames;
|
|
121040
121031
|
}
|
|
121041
121032
|
function resolveModuleNamesReusingOldState(moduleNames, file) {
|
|
121042
|
-
var _a2;
|
|
121033
|
+
var _a2, _b2;
|
|
121043
121034
|
if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
|
|
121044
121035
|
return resolveModuleNamesWorker(
|
|
121045
121036
|
moduleNames,
|
|
@@ -121048,24 +121039,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121048
121039
|
void 0
|
|
121049
121040
|
);
|
|
121050
121041
|
}
|
|
121051
|
-
const oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
|
|
121052
|
-
if (oldSourceFile !== file && file.resolvedModules) {
|
|
121053
|
-
const result2 = [];
|
|
121054
|
-
for (const moduleName of moduleNames) {
|
|
121055
|
-
const resolvedModule = file.resolvedModules.get(moduleName.text, getModeForUsageLocation(file, moduleName));
|
|
121056
|
-
result2.push(resolvedModule);
|
|
121057
|
-
}
|
|
121058
|
-
return result2;
|
|
121059
|
-
}
|
|
121060
121042
|
let unknownModuleNames;
|
|
121061
121043
|
let result;
|
|
121062
121044
|
let reusedNames;
|
|
121063
121045
|
const predictedToResolveToAmbientModuleMarker = emptyResolution;
|
|
121046
|
+
const oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
|
|
121064
121047
|
for (let i = 0; i < moduleNames.length; i++) {
|
|
121065
121048
|
const moduleName = moduleNames[i];
|
|
121066
|
-
if (file === oldSourceFile && !hasInvalidatedResolutions(
|
|
121049
|
+
if (file === oldSourceFile && !hasInvalidatedResolutions(file.path)) {
|
|
121067
121050
|
const mode = getModeForUsageLocation(file, moduleName);
|
|
121068
|
-
const oldResolution = (_a2 =
|
|
121051
|
+
const oldResolution = (_b2 = (_a2 = oldProgram == null ? void 0 : oldProgram.resolvedModules) == null ? void 0 : _a2.get(file.path)) == null ? void 0 : _b2.get(moduleName.text, mode);
|
|
121069
121052
|
if (oldResolution == null ? void 0 : oldResolution.resolvedModule) {
|
|
121070
121053
|
if (isTraceEnabled(options, host)) {
|
|
121071
121054
|
trace(
|
|
@@ -121112,7 +121095,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121112
121095
|
Debug.assert(j === resolutions.length);
|
|
121113
121096
|
return result;
|
|
121114
121097
|
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
|
|
121115
|
-
|
|
121098
|
+
var _a3, _b3, _c2;
|
|
121099
|
+
const resolutionToFile = (_c2 = (_b3 = (_a3 = oldProgram == null ? void 0 : oldProgram.resolvedModules) == null ? void 0 : _a3.get(file.path)) == null ? void 0 : _b3.get(moduleName.text, getModeForUsageLocation(file, moduleName))) == null ? void 0 : _c2.resolvedModule;
|
|
121116
121100
|
const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
|
|
121117
121101
|
if (resolutionToFile && resolvedFile) {
|
|
121118
121102
|
return false;
|
|
@@ -121128,7 +121112,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121128
121112
|
}
|
|
121129
121113
|
}
|
|
121130
121114
|
function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
|
|
121131
|
-
var _a2;
|
|
121115
|
+
var _a2, _b2;
|
|
121132
121116
|
if (structureIsReused === 0 /* Not */) {
|
|
121133
121117
|
return resolveTypeReferenceDirectiveNamesWorker(
|
|
121134
121118
|
typeDirectiveNames,
|
|
@@ -121137,28 +121121,18 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121137
121121
|
void 0
|
|
121138
121122
|
);
|
|
121139
121123
|
}
|
|
121140
|
-
const oldSourceFile = !isString(containingFile) ? oldProgram && oldProgram.getSourceFile(containingFile.fileName) : void 0;
|
|
121141
|
-
if (!isString(containingFile)) {
|
|
121142
|
-
if (oldSourceFile !== containingFile && containingFile.resolvedTypeReferenceDirectiveNames) {
|
|
121143
|
-
const result2 = [];
|
|
121144
|
-
for (const typeDirectiveName of typeDirectiveNames) {
|
|
121145
|
-
const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getTypeReferenceResolutionName(typeDirectiveName), getModeForFileReference(typeDirectiveName, containingFile.impliedNodeFormat));
|
|
121146
|
-
result2.push(resolvedTypeReferenceDirective);
|
|
121147
|
-
}
|
|
121148
|
-
return result2;
|
|
121149
|
-
}
|
|
121150
|
-
}
|
|
121151
121124
|
let unknownTypeReferenceDirectiveNames;
|
|
121152
121125
|
let result;
|
|
121153
121126
|
let reusedNames;
|
|
121154
121127
|
const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
|
|
121155
|
-
const
|
|
121128
|
+
const oldSourceFile = !isString(containingFile) ? oldProgram && oldProgram.getSourceFile(containingFile.fileName) : void 0;
|
|
121129
|
+
const canReuseResolutions = !isString(containingFile) ? containingFile === oldSourceFile && !hasInvalidatedResolutions(containingFile.path) : !hasInvalidatedResolutions(toPath3(containingFile));
|
|
121156
121130
|
for (let i = 0; i < typeDirectiveNames.length; i++) {
|
|
121157
121131
|
const entry = typeDirectiveNames[i];
|
|
121158
121132
|
if (canReuseResolutions) {
|
|
121159
121133
|
const typeDirectiveName = getTypeReferenceResolutionName(entry);
|
|
121160
121134
|
const mode = getModeForFileReference(entry, containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat);
|
|
121161
|
-
const oldResolution = (
|
|
121135
|
+
const oldResolution = (_b2 = !isString(containingFile) ? (_a2 = oldProgram == null ? void 0 : oldProgram.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _a2.get(containingFile.path) : oldProgram == null ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions()) == null ? void 0 : _b2.get(typeDirectiveName, mode);
|
|
121162
121136
|
if (oldResolution == null ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
|
|
121163
121137
|
if (isTraceEnabled(options, host)) {
|
|
121164
121138
|
trace(
|
|
@@ -121218,7 +121192,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121218
121192
|
);
|
|
121219
121193
|
}
|
|
121220
121194
|
function tryReuseStructureFromOldProgram() {
|
|
121221
|
-
var _a2;
|
|
121195
|
+
var _a2, _b2, _c2;
|
|
121222
121196
|
if (!oldProgram) {
|
|
121223
121197
|
return 0 /* Not */;
|
|
121224
121198
|
}
|
|
@@ -121320,42 +121294,37 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121320
121294
|
structureIsReused = 1 /* SafeModules */;
|
|
121321
121295
|
}
|
|
121322
121296
|
}
|
|
121323
|
-
modifiedSourceFiles.push(
|
|
121297
|
+
modifiedSourceFiles.push(newSourceFile);
|
|
121324
121298
|
} else if (hasInvalidatedResolutions(oldSourceFile.path)) {
|
|
121325
121299
|
structureIsReused = 1 /* SafeModules */;
|
|
121326
|
-
modifiedSourceFiles.push(
|
|
121300
|
+
modifiedSourceFiles.push(newSourceFile);
|
|
121301
|
+
} else {
|
|
121302
|
+
for (const moduleName of oldSourceFile.ambientModuleNames) {
|
|
121303
|
+
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldSourceFile.fileName);
|
|
121304
|
+
}
|
|
121327
121305
|
}
|
|
121328
121306
|
newSourceFiles.push(newSourceFile);
|
|
121329
121307
|
}
|
|
121330
121308
|
if (structureIsReused !== 2 /* Completely */) {
|
|
121331
121309
|
return structureIsReused;
|
|
121332
121310
|
}
|
|
121333
|
-
const
|
|
121334
|
-
for (const oldFile of oldSourceFiles) {
|
|
121335
|
-
if (!contains(modifiedFiles, oldFile)) {
|
|
121336
|
-
for (const moduleName of oldFile.ambientModuleNames) {
|
|
121337
|
-
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
|
|
121338
|
-
}
|
|
121339
|
-
}
|
|
121340
|
-
}
|
|
121341
|
-
for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
|
|
121311
|
+
for (const newSourceFile of modifiedSourceFiles) {
|
|
121342
121312
|
const moduleNames = getModuleNames(newSourceFile);
|
|
121343
121313
|
const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
121344
|
-
|
|
121345
|
-
|
|
121314
|
+
(resolvedModulesProcessing ?? (resolvedModulesProcessing = /* @__PURE__ */ new Map())).set(newSourceFile.path, resolutions);
|
|
121315
|
+
const oldResolutions = (_b2 = oldProgram.resolvedModules) == null ? void 0 : _b2.get(newSourceFile.path);
|
|
121316
|
+
const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldResolutions, moduleResolutionIsEqualTo, moduleResolutionNameAndModeGetter);
|
|
121317
|
+
if (resolutionsChanged)
|
|
121346
121318
|
structureIsReused = 1 /* SafeModules */;
|
|
121347
|
-
newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions, moduleResolutionNameAndModeGetter);
|
|
121348
|
-
} else {
|
|
121349
|
-
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
121350
|
-
}
|
|
121351
121319
|
const typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
121352
121320
|
const typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
|
|
121353
|
-
|
|
121321
|
+
(resolvedTypeReferenceDirectiveNamesProcessing ?? (resolvedTypeReferenceDirectiveNamesProcessing = /* @__PURE__ */ new Map())).set(newSourceFile.path, typeReferenceResolutions);
|
|
121322
|
+
const oldTypeResolutions = (_c2 = oldProgram.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _c2.get(newSourceFile.path);
|
|
121323
|
+
const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldTypeResolutions, typeDirectiveIsEqualTo, typeReferenceResolutionNameAndModeGetter);
|
|
121354
121324
|
if (typeReferenceResolutionsChanged) {
|
|
121355
121325
|
structureIsReused = 1 /* SafeModules */;
|
|
121356
|
-
|
|
121357
|
-
|
|
121358
|
-
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
|
121326
|
+
} else if (oldTypeResolutions) {
|
|
121327
|
+
(resolvedTypeReferenceDirectiveNamesProcessing ?? (resolvedTypeReferenceDirectiveNamesProcessing = /* @__PURE__ */ new Map())).set(newSourceFile.path, oldTypeResolutions);
|
|
121359
121328
|
}
|
|
121360
121329
|
}
|
|
121361
121330
|
if (structureIsReused !== 2 /* Completely */) {
|
|
@@ -121403,6 +121372,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121403
121372
|
sourceFileToPackageName = oldProgram.sourceFileToPackageName;
|
|
121404
121373
|
redirectTargetsMap = oldProgram.redirectTargetsMap;
|
|
121405
121374
|
usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
|
|
121375
|
+
resolvedModules = oldProgram.resolvedModules;
|
|
121376
|
+
resolvedTypeReferenceDirectiveNames = oldProgram.resolvedTypeReferenceDirectiveNames;
|
|
121406
121377
|
resolvedLibReferences = oldProgram.resolvedLibReferences;
|
|
121407
121378
|
packageMap = oldProgram.getCurrentPackagesMap();
|
|
121408
121379
|
return 2 /* Completely */;
|
|
@@ -122448,16 +122419,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122448
122419
|
}
|
|
122449
122420
|
function processTypeReferenceDirectives(file) {
|
|
122450
122421
|
const typeDirectives = file.typeReferenceDirectives;
|
|
122451
|
-
if (!typeDirectives.length)
|
|
122452
|
-
file.resolvedTypeReferenceDirectiveNames = void 0;
|
|
122422
|
+
if (!typeDirectives.length)
|
|
122453
122423
|
return;
|
|
122454
|
-
|
|
122455
|
-
const
|
|
122424
|
+
const resolutions = (resolvedTypeReferenceDirectiveNamesProcessing == null ? void 0 : resolvedTypeReferenceDirectiveNamesProcessing.get(file.path)) || resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
|
|
122425
|
+
const resolutionsInFile = createModeAwareCache();
|
|
122426
|
+
(resolvedTypeReferenceDirectiveNames ?? (resolvedTypeReferenceDirectiveNames = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
|
122456
122427
|
for (let index = 0; index < typeDirectives.length; index++) {
|
|
122457
122428
|
const ref = file.typeReferenceDirectives[index];
|
|
122458
122429
|
const resolvedTypeReferenceDirective = resolutions[index];
|
|
122459
122430
|
const fileName = toFileNameLowerCase(ref.fileName);
|
|
122460
|
-
|
|
122431
|
+
resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
|
|
122461
122432
|
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
122462
122433
|
if (mode && getEmitModuleResolutionKind(options) !== 3 /* Node16 */ && getEmitModuleResolutionKind(options) !== 99 /* NodeNext */) {
|
|
122463
122434
|
(fileProcessingDiagnostics ?? (fileProcessingDiagnostics = [])).push({
|
|
@@ -122621,14 +122592,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122621
122592
|
collectExternalModuleReferences(file);
|
|
122622
122593
|
if (file.imports.length || file.moduleAugmentations.length) {
|
|
122623
122594
|
const moduleNames = getModuleNames(file);
|
|
122624
|
-
const resolutions = resolveModuleNamesReusingOldState(moduleNames, file);
|
|
122595
|
+
const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
|
|
122625
122596
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
122626
122597
|
const optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options : void 0) || options;
|
|
122598
|
+
const resolutionsInFile = createModeAwareCache();
|
|
122599
|
+
(resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
|
122627
122600
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
122628
122601
|
const resolution = resolutions[index].resolvedModule;
|
|
122629
122602
|
const moduleName = moduleNames[index].text;
|
|
122630
122603
|
const mode = getModeForUsageLocation(file, moduleNames[index]);
|
|
122631
|
-
|
|
122604
|
+
resolutionsInFile.set(moduleName, mode, resolutions[index]);
|
|
122632
122605
|
addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode);
|
|
122633
122606
|
if (!resolution) {
|
|
122634
122607
|
continue;
|
|
@@ -122659,8 +122632,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122659
122632
|
currentNodeModulesDepth--;
|
|
122660
122633
|
}
|
|
122661
122634
|
}
|
|
122662
|
-
} else {
|
|
122663
|
-
file.resolvedModules = void 0;
|
|
122664
122635
|
}
|
|
122665
122636
|
}
|
|
122666
122637
|
function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
|
|
@@ -123175,7 +123146,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123175
123146
|
processReason(fileProcessingReason);
|
|
123176
123147
|
if (locationReason && (fileIncludeReasons == null ? void 0 : fileIncludeReasons.length) === 1)
|
|
123177
123148
|
fileIncludeReasons = void 0;
|
|
123178
|
-
const location = locationReason && getReferencedFileLocation(
|
|
123149
|
+
const location = locationReason && getReferencedFileLocation(program, locationReason);
|
|
123179
123150
|
const fileIncludeReasonDetails = fileIncludeReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
|
|
123180
123151
|
const redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
|
|
123181
123152
|
const chain = chainDiagnosticMessages(redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails, diagnostic, ...args || emptyArray);
|
|
@@ -123211,7 +123182,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123211
123182
|
}
|
|
123212
123183
|
function fileIncludeReasonToRelatedInformation(reason) {
|
|
123213
123184
|
if (isReferencedFile(reason)) {
|
|
123214
|
-
const referenceLocation = getReferencedFileLocation(
|
|
123185
|
+
const referenceLocation = getReferencedFileLocation(program, reason);
|
|
123215
123186
|
let message2;
|
|
123216
123187
|
switch (reason.kind) {
|
|
123217
123188
|
case 3 /* Import */:
|
|
@@ -123500,8 +123471,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123500
123471
|
if (!symlinks) {
|
|
123501
123472
|
symlinks = createSymlinkCache(currentDirectory, getCanonicalFileName);
|
|
123502
123473
|
}
|
|
123503
|
-
if (files &&
|
|
123504
|
-
symlinks.setSymlinksFromResolutions(
|
|
123474
|
+
if (files && !symlinks.hasProcessedResolutions()) {
|
|
123475
|
+
symlinks.setSymlinksFromResolutions(resolvedModules, resolvedTypeReferenceDirectiveNames, automaticTypeDirectiveResolutions);
|
|
123505
123476
|
}
|
|
123506
123477
|
return symlinks;
|
|
123507
123478
|
}
|
|
@@ -123863,6 +123834,7 @@ var BuilderState;
|
|
|
123863
123834
|
return toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
|
|
123864
123835
|
}
|
|
123865
123836
|
function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
|
|
123837
|
+
var _a;
|
|
123866
123838
|
let referencedFiles;
|
|
123867
123839
|
if (sourceFile.imports && sourceFile.imports.length > 0) {
|
|
123868
123840
|
const checker = program.getTypeChecker();
|
|
@@ -123878,8 +123850,9 @@ var BuilderState;
|
|
|
123878
123850
|
addReferencedFile(referencedPath);
|
|
123879
123851
|
}
|
|
123880
123852
|
}
|
|
123881
|
-
|
|
123882
|
-
|
|
123853
|
+
const resolvedTypeReferenceDirectiveNames = (_a = program.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _a.get(sourceFile.path);
|
|
123854
|
+
if (resolvedTypeReferenceDirectiveNames) {
|
|
123855
|
+
resolvedTypeReferenceDirectiveNames.forEach(({ resolvedTypeReferenceDirective }) => {
|
|
123883
123856
|
if (!resolvedTypeReferenceDirective) {
|
|
123884
123857
|
return;
|
|
123885
123858
|
}
|
|
@@ -125702,10 +125675,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
125702
125675
|
clear: clear2,
|
|
125703
125676
|
onChangesAffectModuleResolution
|
|
125704
125677
|
};
|
|
125705
|
-
function
|
|
125678
|
+
function getResolvedModule(resolution) {
|
|
125706
125679
|
return resolution.resolvedModule;
|
|
125707
125680
|
}
|
|
125708
|
-
function
|
|
125681
|
+
function getResolvedTypeReferenceDirective(resolution) {
|
|
125709
125682
|
return resolution.resolvedTypeReferenceDirective;
|
|
125710
125683
|
}
|
|
125711
125684
|
function clear2() {
|
|
@@ -125781,7 +125754,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
125781
125754
|
stopWatchFailedLookupLocationOfResolution(
|
|
125782
125755
|
resolution,
|
|
125783
125756
|
resolutionHost.toPath(getInferredLibraryNameResolveFrom(newProgram.getCompilerOptions(), getCurrentDirectory(), libFileName)),
|
|
125784
|
-
|
|
125757
|
+
getResolvedModule
|
|
125785
125758
|
);
|
|
125786
125759
|
resolvedLibraries.delete(libFileName);
|
|
125787
125760
|
}
|
|
@@ -125987,7 +125960,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
125987
125960
|
((_a = resolutionHost.getCompilerHost) == null ? void 0 : _a.call(resolutionHost)) || resolutionHost,
|
|
125988
125961
|
typeReferenceDirectiveResolutionCache
|
|
125989
125962
|
),
|
|
125990
|
-
getResolutionWithResolvedFileName:
|
|
125963
|
+
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
|
|
125991
125964
|
shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
|
|
125992
125965
|
deferWatchingNonRelativeResolution: false
|
|
125993
125966
|
});
|
|
@@ -126006,7 +125979,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
126006
125979
|
redirectedReference,
|
|
126007
125980
|
options
|
|
126008
125981
|
),
|
|
126009
|
-
getResolutionWithResolvedFileName:
|
|
125982
|
+
getResolutionWithResolvedFileName: getResolvedModule,
|
|
126010
125983
|
shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
|
|
126011
125984
|
logChanges: logChangesWhenResolvingModule,
|
|
126012
125985
|
deferWatchingNonRelativeResolution: true
|
|
@@ -126025,17 +125998,17 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
126025
125998
|
libraryName,
|
|
126026
125999
|
resolution,
|
|
126027
126000
|
path,
|
|
126028
|
-
|
|
126001
|
+
getResolvedModule,
|
|
126029
126002
|
/*deferWatchingNonRelativeResolution*/
|
|
126030
126003
|
false
|
|
126031
126004
|
);
|
|
126032
126005
|
resolvedLibraries.set(libFileName, resolution);
|
|
126033
126006
|
if (existingResolution) {
|
|
126034
|
-
stopWatchFailedLookupLocationOfResolution(existingResolution, path,
|
|
126007
|
+
stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModule);
|
|
126035
126008
|
}
|
|
126036
126009
|
} else {
|
|
126037
126010
|
if (isTraceEnabled(options, host)) {
|
|
126038
|
-
const resolved =
|
|
126011
|
+
const resolved = getResolvedModule(resolution);
|
|
126039
126012
|
trace(
|
|
126040
126013
|
host,
|
|
126041
126014
|
(resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved,
|
|
@@ -126312,8 +126285,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
126312
126285
|
resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
|
|
126313
126286
|
}
|
|
126314
126287
|
function removeResolutionsOfFile(filePath) {
|
|
126315
|
-
removeResolutionsOfFileFromCache(resolvedModuleNames, filePath,
|
|
126316
|
-
removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath,
|
|
126288
|
+
removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
|
|
126289
|
+
removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
|
|
126317
126290
|
}
|
|
126318
126291
|
function invalidateResolutions(resolutions, canInvalidate) {
|
|
126319
126292
|
if (!resolutions)
|
|
@@ -126739,7 +126712,7 @@ function fileIncludeReasonToDiagnostics(program, reason, fileNameConvertor) {
|
|
|
126739
126712
|
var _a, _b;
|
|
126740
126713
|
const options = program.getCompilerOptions();
|
|
126741
126714
|
if (isReferencedFile(reason)) {
|
|
126742
|
-
const referenceLocation = getReferencedFileLocation(
|
|
126715
|
+
const referenceLocation = getReferencedFileLocation(program, reason);
|
|
126743
126716
|
const referenceText = isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : `"${referenceLocation.text}"`;
|
|
126744
126717
|
let message;
|
|
126745
126718
|
Debug.assert(isReferenceFileLocation(referenceLocation) || reason.kind === 3 /* Import */, "Only synthetic references are imports");
|
|
@@ -135424,14 +135397,14 @@ function combinePathsSafe(pathA, pathB) {
|
|
|
135424
135397
|
return ensurePathIsNonModuleName(combineNormal(pathA, pathB));
|
|
135425
135398
|
}
|
|
135426
135399
|
function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) {
|
|
135427
|
-
var _a;
|
|
135400
|
+
var _a, _b;
|
|
135428
135401
|
if (importedModuleSymbol) {
|
|
135429
135402
|
const oldFileName = find(importedModuleSymbol.declarations, isSourceFile).fileName;
|
|
135430
135403
|
const newFileName = oldToNew(oldFileName);
|
|
135431
135404
|
return newFileName === void 0 ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true };
|
|
135432
135405
|
} else {
|
|
135433
135406
|
const mode = getModeForUsageLocation(importingSourceFile, importLiteral);
|
|
135434
|
-
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? (_a =
|
|
135407
|
+
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(importingSourceFile.path)) == null ? void 0 : _b.get(importLiteral.text, mode) : host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
|
135435
135408
|
return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
|
|
135436
135409
|
}
|
|
135437
135410
|
}
|
|
@@ -136326,6 +136299,7 @@ function createSourceFileLike(text, lineMap) {
|
|
|
136326
136299
|
// src/services/suggestionDiagnostics.ts
|
|
136327
136300
|
var visitedNestedConvertibleFunctions = /* @__PURE__ */ new Map();
|
|
136328
136301
|
function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
136302
|
+
var _a, _b, _c;
|
|
136329
136303
|
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
136330
136304
|
const diags = [];
|
|
136331
136305
|
const checker = program.getTypeChecker();
|
|
@@ -136342,7 +136316,7 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
136342
136316
|
const name = importNameForConvertToDefaultImport(importNode);
|
|
136343
136317
|
if (!name)
|
|
136344
136318
|
continue;
|
|
136345
|
-
const module2 =
|
|
136319
|
+
const module2 = (_c = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(sourceFile.path)) == null ? void 0 : _b.get(moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier))) == null ? void 0 : _c.resolvedModule;
|
|
136346
136320
|
const resolvedFile = module2 && program.getSourceFile(module2.resolvedFileName);
|
|
136347
136321
|
if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
|
|
136348
136322
|
diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import));
|
|
@@ -138745,10 +138719,10 @@ function getTargetFileImportsAndAddExportInOldFile(oldFile, targetFile, importsT
|
|
|
138745
138719
|
const targetSourceFile = program.getSourceFile(targetFile);
|
|
138746
138720
|
for (const oldStatement of oldFile.statements) {
|
|
138747
138721
|
forEachImportInStatement(oldStatement, (i) => {
|
|
138748
|
-
var _a, _b;
|
|
138722
|
+
var _a, _b, _c;
|
|
138749
138723
|
const moduleSpecifier = moduleSpecifierFromImport(i);
|
|
138750
|
-
const resolved = (_a =
|
|
138751
|
-
const fileName = (
|
|
138724
|
+
const resolved = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(oldFile.path)) == null ? void 0 : _b.get(moduleSpecifier.text, getModeForUsageLocation(oldFile, moduleSpecifier));
|
|
138725
|
+
const fileName = (_c = resolved == null ? void 0 : resolved.resolvedModule) == null ? void 0 : _c.resolvedFileName;
|
|
138752
138726
|
if (fileName && targetSourceFile) {
|
|
138753
138727
|
const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), targetSourceFile, targetSourceFile.path, fileName, createModuleSpecifierResolutionHost(program, host));
|
|
138754
138728
|
append(copiedOldImports, filterImport(i, makeStringLiteral(newModuleSpecifier, quotePreference), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
|
|
@@ -149022,16 +148996,17 @@ registerCodeFix({
|
|
|
149022
148996
|
const moduleExportsChangedToDefault = convertFileToEsModule(sourceFile, program.getTypeChecker(), changes2, getEmitScriptTarget(program.getCompilerOptions()), getQuotePreference(sourceFile, preferences));
|
|
149023
148997
|
if (moduleExportsChangedToDefault) {
|
|
149024
148998
|
for (const importingFile of program.getSourceFiles()) {
|
|
149025
|
-
fixImportOfModuleExports(importingFile, sourceFile, changes2, getQuotePreference(importingFile, preferences));
|
|
148999
|
+
fixImportOfModuleExports(importingFile, sourceFile, program, changes2, getQuotePreference(importingFile, preferences));
|
|
149026
149000
|
}
|
|
149027
149001
|
}
|
|
149028
149002
|
});
|
|
149029
149003
|
return [createCodeFixActionWithoutFixAll("convertToEsModule", changes, Diagnostics.Convert_to_ES_module)];
|
|
149030
149004
|
}
|
|
149031
149005
|
});
|
|
149032
|
-
function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
|
|
149006
|
+
function fixImportOfModuleExports(importingFile, exportingFile, program, changes, quotePreference) {
|
|
149007
|
+
var _a, _b, _c;
|
|
149033
149008
|
for (const moduleSpecifier of importingFile.imports) {
|
|
149034
|
-
const imported =
|
|
149009
|
+
const imported = (_c = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(importingFile.path)) == null ? void 0 : _b.get(moduleSpecifier.text, getModeForUsageLocation(importingFile, moduleSpecifier))) == null ? void 0 : _c.resolvedModule;
|
|
149035
149010
|
if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
|
|
149036
149011
|
continue;
|
|
149037
149012
|
}
|
|
@@ -150184,7 +150159,7 @@ registerCodeFix({
|
|
|
150184
150159
|
fix,
|
|
150185
150160
|
/*includeSymbolNameInDescription*/
|
|
150186
150161
|
symbolName2 !== errorIdentifierText,
|
|
150187
|
-
program
|
|
150162
|
+
program,
|
|
150188
150163
|
preferences
|
|
150189
150164
|
)
|
|
150190
150165
|
);
|
|
@@ -150433,7 +150408,6 @@ function createImportSpecifierResolver(importingFile, program, host, preferences
|
|
|
150433
150408
|
}
|
|
150434
150409
|
}
|
|
150435
150410
|
function getImportCompletionAction(targetSymbol, moduleSymbol, exportMapKey, sourceFile, symbolName2, isJsxTagName, host, program, formatContext, position, preferences, cancellationToken) {
|
|
150436
|
-
const compilerOptions = program.getCompilerOptions();
|
|
150437
150411
|
let exportInfos;
|
|
150438
150412
|
if (exportMapKey) {
|
|
150439
150413
|
exportInfos = getExportInfoMap(sourceFile, host, program, preferences, cancellationToken).get(sourceFile.path, exportMapKey);
|
|
@@ -150454,7 +150428,7 @@ function getImportCompletionAction(targetSymbol, moduleSymbol, exportMapKey, sou
|
|
|
150454
150428
|
fix,
|
|
150455
150429
|
/*includeSymbolNameInDescription*/
|
|
150456
150430
|
false,
|
|
150457
|
-
|
|
150431
|
+
program,
|
|
150458
150432
|
preferences
|
|
150459
150433
|
))
|
|
150460
150434
|
};
|
|
@@ -150464,7 +150438,15 @@ function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, ho
|
|
|
150464
150438
|
const symbolName2 = single(getSymbolNamesToImport(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions));
|
|
150465
150439
|
const fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName2, program);
|
|
150466
150440
|
const includeSymbolNameInDescription = symbolName2 !== symbolToken.text;
|
|
150467
|
-
return fix && codeFixActionToCodeAction(codeActionForFix(
|
|
150441
|
+
return fix && codeFixActionToCodeAction(codeActionForFix(
|
|
150442
|
+
{ host, formatContext, preferences },
|
|
150443
|
+
sourceFile,
|
|
150444
|
+
symbolName2,
|
|
150445
|
+
fix,
|
|
150446
|
+
includeSymbolNameInDescription,
|
|
150447
|
+
program,
|
|
150448
|
+
preferences
|
|
150449
|
+
));
|
|
150468
150450
|
}
|
|
150469
150451
|
function getImportFixForSymbol(sourceFile, exportInfos, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
150470
150452
|
const packageJsonImportFilter = createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
@@ -151034,14 +151016,14 @@ function getExportEqualsImportKind(importingFile, compilerOptions, forceImportKe
|
|
|
151034
151016
|
}
|
|
151035
151017
|
return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
|
|
151036
151018
|
}
|
|
151037
|
-
function codeActionForFix(context, sourceFile, symbolName2, fix, includeSymbolNameInDescription,
|
|
151019
|
+
function codeActionForFix(context, sourceFile, symbolName2, fix, includeSymbolNameInDescription, program, preferences) {
|
|
151038
151020
|
let diag2;
|
|
151039
151021
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
|
|
151040
|
-
diag2 = codeActionForFixWorker(tracker, sourceFile, symbolName2, fix, includeSymbolNameInDescription,
|
|
151022
|
+
diag2 = codeActionForFixWorker(tracker, sourceFile, symbolName2, fix, includeSymbolNameInDescription, program, preferences);
|
|
151041
151023
|
});
|
|
151042
151024
|
return createCodeFixAction(importFixName, changes, diag2, importFixId, Diagnostics.Add_all_missing_imports);
|
|
151043
151025
|
}
|
|
151044
|
-
function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSymbolNameInDescription,
|
|
151026
|
+
function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSymbolNameInDescription, program, preferences) {
|
|
151045
151027
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
151046
151028
|
switch (fix.kind) {
|
|
151047
151029
|
case 0 /* UseNamespace */:
|
|
@@ -151078,7 +151060,7 @@ function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSy
|
|
|
151078
151060
|
defaultImport,
|
|
151079
151061
|
namedImports,
|
|
151080
151062
|
namespaceLikeImport,
|
|
151081
|
-
|
|
151063
|
+
program.getCompilerOptions()
|
|
151082
151064
|
),
|
|
151083
151065
|
/*blankLineBetween*/
|
|
151084
151066
|
true,
|
|
@@ -151091,7 +151073,7 @@ function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSy
|
|
|
151091
151073
|
}
|
|
151092
151074
|
case 4 /* PromoteTypeOnly */: {
|
|
151093
151075
|
const { typeOnlyAliasDeclaration } = fix;
|
|
151094
|
-
const promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration,
|
|
151076
|
+
const promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, program, sourceFile, preferences);
|
|
151095
151077
|
return promotedDeclaration.kind === 276 /* ImportSpecifier */ ? [Diagnostics.Remove_type_from_import_of_0_from_1, symbolName2, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
|
|
151096
151078
|
}
|
|
151097
151079
|
default:
|
|
@@ -151102,7 +151084,8 @@ function getModuleSpecifierText(promotedDeclaration) {
|
|
|
151102
151084
|
var _a, _b;
|
|
151103
151085
|
return promotedDeclaration.kind === 271 /* ImportEqualsDeclaration */ ? ((_b = tryCast((_a = tryCast(promotedDeclaration.moduleReference, isExternalModuleReference)) == null ? void 0 : _a.expression, isStringLiteralLike)) == null ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : cast(promotedDeclaration.parent.moduleSpecifier, isStringLiteral).text;
|
|
151104
151086
|
}
|
|
151105
|
-
function promoteFromTypeOnly(changes, aliasDeclaration,
|
|
151087
|
+
function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, preferences) {
|
|
151088
|
+
const compilerOptions = program.getCompilerOptions();
|
|
151106
151089
|
const convertExistingToTypeOnly = importNameElisionDisabled(compilerOptions);
|
|
151107
151090
|
switch (aliasDeclaration.kind) {
|
|
151108
151091
|
case 276 /* ImportSpecifier */:
|
|
@@ -151144,10 +151127,11 @@ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceF
|
|
|
151144
151127
|
Debug.failBadSyntaxKind(aliasDeclaration);
|
|
151145
151128
|
}
|
|
151146
151129
|
function promoteImportClause(importClause) {
|
|
151130
|
+
var _a, _b, _c;
|
|
151147
151131
|
changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
151148
151132
|
if (!compilerOptions.allowImportingTsExtensions) {
|
|
151149
151133
|
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent);
|
|
151150
|
-
const resolvedModule = moduleSpecifier &&
|
|
151134
|
+
const resolvedModule = moduleSpecifier && ((_c = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(sourceFile.path)) == null ? void 0 : _b.get(moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier))) == null ? void 0 : _c.resolvedModule);
|
|
151151
151135
|
if (resolvedModule == null ? void 0 : resolvedModule.resolvedUsingTsExtension) {
|
|
151152
151136
|
const changedExtension = changeAnyExtension(moduleSpecifier.text, getOutputExtension(moduleSpecifier.text, compilerOptions));
|
|
151153
151137
|
changes.replaceNode(sourceFile, moduleSpecifier, factory.createStringLiteral(changedExtension));
|
|
@@ -151815,7 +151799,7 @@ registerCodeFix({
|
|
|
151815
151799
|
}
|
|
151816
151800
|
});
|
|
151817
151801
|
function getInfo7(sourceFile, pos, program) {
|
|
151818
|
-
var _a;
|
|
151802
|
+
var _a, _b, _c, _d;
|
|
151819
151803
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
151820
151804
|
if (isIdentifier(token)) {
|
|
151821
151805
|
const importDeclaration = findAncestor(token, isImportDeclaration);
|
|
@@ -151824,19 +151808,18 @@ function getInfo7(sourceFile, pos, program) {
|
|
|
151824
151808
|
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : void 0;
|
|
151825
151809
|
if (moduleSpecifier === void 0)
|
|
151826
151810
|
return void 0;
|
|
151827
|
-
const resolvedModule =
|
|
151828
|
-
sourceFile,
|
|
151811
|
+
const resolvedModule = (_c = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(sourceFile.path)) == null ? void 0 : _b.get(
|
|
151829
151812
|
moduleSpecifier,
|
|
151830
151813
|
/*mode*/
|
|
151831
151814
|
void 0
|
|
151832
|
-
);
|
|
151815
|
+
)) == null ? void 0 : _c.resolvedModule;
|
|
151833
151816
|
if (resolvedModule === void 0)
|
|
151834
151817
|
return void 0;
|
|
151835
151818
|
const moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
151836
151819
|
if (moduleSourceFile === void 0 || isSourceFileFromLibrary(program, moduleSourceFile))
|
|
151837
151820
|
return void 0;
|
|
151838
151821
|
const moduleSymbol = moduleSourceFile.symbol;
|
|
151839
|
-
const locals = (
|
|
151822
|
+
const locals = (_d = tryCast(moduleSymbol.valueDeclaration, canHaveLocals)) == null ? void 0 : _d.locals;
|
|
151840
151823
|
if (locals === void 0)
|
|
151841
151824
|
return void 0;
|
|
151842
151825
|
const localSymbol = locals.get(token.escapedText);
|
|
@@ -152091,9 +152074,10 @@ function convertSemanticMeaningToSymbolFlags(meaning) {
|
|
|
152091
152074
|
return flags;
|
|
152092
152075
|
}
|
|
152093
152076
|
function getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration) {
|
|
152077
|
+
var _a, _b, _c;
|
|
152094
152078
|
if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier))
|
|
152095
152079
|
return void 0;
|
|
152096
|
-
const resolvedModule =
|
|
152080
|
+
const resolvedModule = (_c = (_b = (_a = context.program.resolvedModules) == null ? void 0 : _a.get(sourceFile.path)) == null ? void 0 : _b.get(importDeclaration.moduleSpecifier.text, getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier))) == null ? void 0 : _c.resolvedModule;
|
|
152097
152081
|
if (!resolvedModule)
|
|
152098
152082
|
return void 0;
|
|
152099
152083
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -162896,7 +162880,7 @@ function declarationIsWriteAccess(decl) {
|
|
|
162896
162880
|
var Core;
|
|
162897
162881
|
((Core2) => {
|
|
162898
162882
|
function getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options = {}, sourceFilesSet = new Set(sourceFiles.map((f) => f.fileName))) {
|
|
162899
|
-
var _a, _b, _c;
|
|
162883
|
+
var _a, _b, _c, _d;
|
|
162900
162884
|
node = getAdjustedNode2(node, options);
|
|
162901
162885
|
if (isSourceFile(node)) {
|
|
162902
162886
|
const resolvedRef = ts_GoToDefinition_exports.getReferenceAtPosition(node, position, program);
|
|
@@ -162935,7 +162919,7 @@ var Core;
|
|
|
162935
162919
|
if (!options.implementations && isStringLiteralLike(node)) {
|
|
162936
162920
|
if (isModuleSpecifierLike(node)) {
|
|
162937
162921
|
const fileIncludeReasons = program.getFileIncludeReasons();
|
|
162938
|
-
const referencedFileName = (_c = (_b = (_a = node.getSourceFile().
|
|
162922
|
+
const referencedFileName = (_d = (_c = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(node.getSourceFile().path)) == null ? void 0 : _b.get(node.text, getModeForUsageLocation(node.getSourceFile(), node))) == null ? void 0 : _c.resolvedModule) == null ? void 0 : _d.resolvedFileName;
|
|
162939
162923
|
const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : void 0;
|
|
162940
162924
|
if (referencedFile) {
|
|
162941
162925
|
return [{ definition: { type: 4 /* String */, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }];
|
|
@@ -162998,7 +162982,7 @@ var Core;
|
|
|
162998
162982
|
for (const ref of references) {
|
|
162999
162983
|
if (isReferencedFile(ref)) {
|
|
163000
162984
|
const referencingFile = program.getSourceFileByPath(ref.file);
|
|
163001
|
-
const location = getReferencedFileLocation(program
|
|
162985
|
+
const location = getReferencedFileLocation(program, ref);
|
|
163002
162986
|
if (isReferenceFileLocation(location)) {
|
|
163003
162987
|
entries = append(entries, {
|
|
163004
162988
|
kind: 0 /* Span */,
|
|
@@ -164338,7 +164322,7 @@ __export(ts_GoToDefinition_exports, {
|
|
|
164338
164322
|
|
|
164339
164323
|
// src/services/goToDefinition.ts
|
|
164340
164324
|
function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) {
|
|
164341
|
-
var _a, _b;
|
|
164325
|
+
var _a, _b, _c;
|
|
164342
164326
|
const resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
164343
164327
|
const fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || emptyArray;
|
|
164344
164328
|
if (resolvedRef == null ? void 0 : resolvedRef.file) {
|
|
@@ -164411,7 +164395,7 @@ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFiles
|
|
|
164411
164395
|
}
|
|
164412
164396
|
}
|
|
164413
164397
|
if (!symbol && isModuleSpecifierLike(fallbackNode)) {
|
|
164414
|
-
const ref = (_b = (_a =
|
|
164398
|
+
const ref = (_c = (_b = (_a = program.resolvedModules) == null ? void 0 : _a.get(sourceFile.path)) == null ? void 0 : _b.get(fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode))) == null ? void 0 : _c.resolvedModule;
|
|
164415
164399
|
if (ref) {
|
|
164416
164400
|
return [{
|
|
164417
164401
|
name: fallbackNode.text,
|
|
@@ -164523,10 +164507,11 @@ function getReferenceAtPosition(sourceFile, position, program) {
|
|
|
164523
164507
|
const file = program.getLibFileFromReference(libReferenceDirective);
|
|
164524
164508
|
return file && { reference: libReferenceDirective, fileName: file.fileName, file, unverified: false };
|
|
164525
164509
|
}
|
|
164526
|
-
|
|
164510
|
+
const resolvedModules = (_b = program.resolvedModules) == null ? void 0 : _b.get(sourceFile.path);
|
|
164511
|
+
if (resolvedModules == null ? void 0 : resolvedModules.size()) {
|
|
164527
164512
|
const node = getTouchingToken(sourceFile, position);
|
|
164528
|
-
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) &&
|
|
164529
|
-
const verifiedFileName = (_d = (_c =
|
|
164513
|
+
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && resolvedModules.has(node.text, getModeForUsageLocation(sourceFile, node))) {
|
|
164514
|
+
const verifiedFileName = (_d = (_c = resolvedModules.get(node.text, getModeForUsageLocation(sourceFile, node))) == null ? void 0 : _c.resolvedModule) == null ? void 0 : _d.resolvedFileName;
|
|
164530
164515
|
const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
|
|
164531
164516
|
return {
|
|
164532
164517
|
file: program.getSourceFile(fileName),
|
|
@@ -164863,7 +164848,6 @@ __export(ts_InlayHints_exports, {
|
|
|
164863
164848
|
});
|
|
164864
164849
|
|
|
164865
164850
|
// src/services/inlayHints.ts
|
|
164866
|
-
var maxTypeHintLength = 30;
|
|
164867
164851
|
var leadingParameterNameCommentRegexFactory = (name) => {
|
|
164868
164852
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164869
164853
|
};
|
|
@@ -164943,9 +164927,10 @@ function provideInlayHints(context) {
|
|
|
164943
164927
|
displayParts
|
|
164944
164928
|
});
|
|
164945
164929
|
}
|
|
164946
|
-
function addTypeHints(
|
|
164930
|
+
function addTypeHints(hintText, position) {
|
|
164947
164931
|
result.push({
|
|
164948
|
-
text:
|
|
164932
|
+
text: typeof hintText === "string" ? `: ${hintText}` : "",
|
|
164933
|
+
displayParts: typeof hintText === "string" ? void 0 : [{ text: ": " }, ...hintText],
|
|
164949
164934
|
position,
|
|
164950
164935
|
kind: "Type" /* Type */,
|
|
164951
164936
|
whitespaceBefore: true
|
|
@@ -164983,13 +164968,14 @@ function provideInlayHints(context) {
|
|
|
164983
164968
|
if (isModuleReferenceType(declarationType)) {
|
|
164984
164969
|
return;
|
|
164985
164970
|
}
|
|
164986
|
-
const
|
|
164987
|
-
if (
|
|
164988
|
-
const
|
|
164971
|
+
const hints = typeToInlayHintParts(declarationType);
|
|
164972
|
+
if (hints) {
|
|
164973
|
+
const hintText = typeof hints === "string" ? hints : hints.map((part) => part.text).join("");
|
|
164974
|
+
const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), hintText);
|
|
164989
164975
|
if (isVariableNameMatchesType) {
|
|
164990
164976
|
return;
|
|
164991
164977
|
}
|
|
164992
|
-
addTypeHints(
|
|
164978
|
+
addTypeHints(hints, decl.name.end);
|
|
164993
164979
|
}
|
|
164994
164980
|
}
|
|
164995
164981
|
function visitCallOrNewExpression(expr) {
|
|
@@ -165097,11 +165083,10 @@ function provideInlayHints(context) {
|
|
|
165097
165083
|
if (isModuleReferenceType(returnType)) {
|
|
165098
165084
|
return;
|
|
165099
165085
|
}
|
|
165100
|
-
const
|
|
165101
|
-
if (
|
|
165102
|
-
|
|
165086
|
+
const hint = typeToInlayHintParts(returnType);
|
|
165087
|
+
if (hint) {
|
|
165088
|
+
addTypeHints(hint, getTypeAnnotationPosition(decl));
|
|
165103
165089
|
}
|
|
165104
|
-
addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl));
|
|
165105
165090
|
}
|
|
165106
165091
|
function getTypeAnnotationPosition(decl) {
|
|
165107
165092
|
const closeParenToken = findChildOfKind(decl, 22 /* CloseParenToken */, file);
|
|
@@ -165162,6 +165147,303 @@ function provideInlayHints(context) {
|
|
|
165162
165147
|
);
|
|
165163
165148
|
});
|
|
165164
165149
|
}
|
|
165150
|
+
function typeToInlayHintParts(type) {
|
|
165151
|
+
if (!shouldUseInteractiveInlayHints(preferences)) {
|
|
165152
|
+
return printTypeInSingleLine(type);
|
|
165153
|
+
}
|
|
165154
|
+
const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
|
|
165155
|
+
const typeNode = checker.typeToTypeNode(
|
|
165156
|
+
type,
|
|
165157
|
+
/*enclosingDeclaration*/
|
|
165158
|
+
void 0,
|
|
165159
|
+
flags
|
|
165160
|
+
);
|
|
165161
|
+
Debug.assertIsDefined(typeNode, "should always get typenode");
|
|
165162
|
+
const parts = [];
|
|
165163
|
+
visitForDisplayParts(typeNode);
|
|
165164
|
+
return parts;
|
|
165165
|
+
function visitForDisplayParts(node) {
|
|
165166
|
+
if (!node) {
|
|
165167
|
+
return;
|
|
165168
|
+
}
|
|
165169
|
+
const tokenString = tokenToString(node.kind);
|
|
165170
|
+
if (tokenString) {
|
|
165171
|
+
parts.push({ text: tokenString });
|
|
165172
|
+
return;
|
|
165173
|
+
}
|
|
165174
|
+
switch (node.kind) {
|
|
165175
|
+
case 80 /* Identifier */:
|
|
165176
|
+
const identifier = node;
|
|
165177
|
+
const identifierText = idText(identifier);
|
|
165178
|
+
const name = identifier.symbol && identifier.symbol.declarations && identifier.symbol.declarations.length && getNameOfDeclaration(identifier.symbol.declarations[0]);
|
|
165179
|
+
if (name) {
|
|
165180
|
+
parts.push(getNodeDisplayPart(identifierText, name));
|
|
165181
|
+
} else {
|
|
165182
|
+
parts.push({ text: identifierText });
|
|
165183
|
+
}
|
|
165184
|
+
break;
|
|
165185
|
+
case 9 /* NumericLiteral */:
|
|
165186
|
+
parts.push({ text: node.text });
|
|
165187
|
+
break;
|
|
165188
|
+
case 11 /* StringLiteral */:
|
|
165189
|
+
parts.push({ text: `"${node.text}"` });
|
|
165190
|
+
break;
|
|
165191
|
+
case 166 /* QualifiedName */:
|
|
165192
|
+
const qualifiedName = node;
|
|
165193
|
+
visitForDisplayParts(qualifiedName.left);
|
|
165194
|
+
parts.push({ text: "." });
|
|
165195
|
+
visitForDisplayParts(qualifiedName.right);
|
|
165196
|
+
break;
|
|
165197
|
+
case 182 /* TypePredicate */:
|
|
165198
|
+
const predicate = node;
|
|
165199
|
+
if (predicate.assertsModifier) {
|
|
165200
|
+
parts.push({ text: "asserts " });
|
|
165201
|
+
}
|
|
165202
|
+
visitForDisplayParts(predicate.parameterName);
|
|
165203
|
+
if (predicate.type) {
|
|
165204
|
+
parts.push({ text: " is " });
|
|
165205
|
+
visitForDisplayParts(predicate.type);
|
|
165206
|
+
}
|
|
165207
|
+
break;
|
|
165208
|
+
case 183 /* TypeReference */:
|
|
165209
|
+
const typeReference = node;
|
|
165210
|
+
visitForDisplayParts(typeReference.typeName);
|
|
165211
|
+
if (typeReference.typeArguments) {
|
|
165212
|
+
parts.push({ text: "<" });
|
|
165213
|
+
visitDisplayPartList(typeReference.typeArguments, ", ");
|
|
165214
|
+
parts.push({ text: ">" });
|
|
165215
|
+
}
|
|
165216
|
+
break;
|
|
165217
|
+
case 168 /* TypeParameter */:
|
|
165218
|
+
const typeParameter = node;
|
|
165219
|
+
if (typeParameter.modifiers) {
|
|
165220
|
+
visitDisplayPartList(typeParameter.modifiers, " ");
|
|
165221
|
+
}
|
|
165222
|
+
visitForDisplayParts(typeParameter.name);
|
|
165223
|
+
if (typeParameter.constraint) {
|
|
165224
|
+
parts.push({ text: " extends " });
|
|
165225
|
+
visitForDisplayParts(typeParameter.constraint);
|
|
165226
|
+
}
|
|
165227
|
+
if (typeParameter.default) {
|
|
165228
|
+
parts.push({ text: " = " });
|
|
165229
|
+
visitForDisplayParts(typeParameter.default);
|
|
165230
|
+
}
|
|
165231
|
+
break;
|
|
165232
|
+
case 169 /* Parameter */:
|
|
165233
|
+
const parameter = node;
|
|
165234
|
+
if (parameter.modifiers) {
|
|
165235
|
+
visitDisplayPartList(parameter.modifiers, " ");
|
|
165236
|
+
}
|
|
165237
|
+
if (parameter.dotDotDotToken) {
|
|
165238
|
+
parts.push({ text: "..." });
|
|
165239
|
+
}
|
|
165240
|
+
visitForDisplayParts(parameter.name);
|
|
165241
|
+
if (parameter.questionToken) {
|
|
165242
|
+
parts.push({ text: "?" });
|
|
165243
|
+
}
|
|
165244
|
+
if (parameter.type) {
|
|
165245
|
+
parts.push({ text: ": " });
|
|
165246
|
+
visitForDisplayParts(parameter.type);
|
|
165247
|
+
}
|
|
165248
|
+
break;
|
|
165249
|
+
case 185 /* ConstructorType */:
|
|
165250
|
+
const constructorType = node;
|
|
165251
|
+
parts.push({ text: "new " });
|
|
165252
|
+
if (constructorType.typeParameters) {
|
|
165253
|
+
parts.push({ text: "<" });
|
|
165254
|
+
visitDisplayPartList(constructorType.typeParameters, ", ");
|
|
165255
|
+
parts.push({ text: ">" });
|
|
165256
|
+
}
|
|
165257
|
+
parts.push({ text: "(" });
|
|
165258
|
+
visitDisplayPartList(constructorType.parameters, ", ");
|
|
165259
|
+
parts.push({ text: ")" });
|
|
165260
|
+
parts.push({ text: " => " });
|
|
165261
|
+
visitForDisplayParts(constructorType.type);
|
|
165262
|
+
break;
|
|
165263
|
+
case 186 /* TypeQuery */:
|
|
165264
|
+
const typeQuery = node;
|
|
165265
|
+
parts.push({ text: "typeof " });
|
|
165266
|
+
visitForDisplayParts(typeQuery.exprName);
|
|
165267
|
+
if (typeQuery.typeArguments) {
|
|
165268
|
+
parts.push({ text: "<" });
|
|
165269
|
+
visitDisplayPartList(typeQuery.typeArguments, ", ");
|
|
165270
|
+
parts.push({ text: ">" });
|
|
165271
|
+
}
|
|
165272
|
+
break;
|
|
165273
|
+
case 187 /* TypeLiteral */:
|
|
165274
|
+
const typeLiteral = node;
|
|
165275
|
+
parts.push({ text: "{" });
|
|
165276
|
+
if (typeLiteral.members.length) {
|
|
165277
|
+
parts.push({ text: " " });
|
|
165278
|
+
visitDisplayPartList(typeLiteral.members, "; ");
|
|
165279
|
+
parts.push({ text: " " });
|
|
165280
|
+
}
|
|
165281
|
+
parts.push({ text: "}" });
|
|
165282
|
+
break;
|
|
165283
|
+
case 188 /* ArrayType */:
|
|
165284
|
+
visitForDisplayParts(node.elementType);
|
|
165285
|
+
parts.push({ text: "[]" });
|
|
165286
|
+
break;
|
|
165287
|
+
case 189 /* TupleType */:
|
|
165288
|
+
parts.push({ text: "[" });
|
|
165289
|
+
visitDisplayPartList(node.elements, ", ");
|
|
165290
|
+
parts.push({ text: "]" });
|
|
165291
|
+
break;
|
|
165292
|
+
case 202 /* NamedTupleMember */:
|
|
165293
|
+
const member = node;
|
|
165294
|
+
if (member.dotDotDotToken) {
|
|
165295
|
+
parts.push({ text: "..." });
|
|
165296
|
+
}
|
|
165297
|
+
visitForDisplayParts(member.name);
|
|
165298
|
+
if (member.questionToken) {
|
|
165299
|
+
parts.push({ text: "?" });
|
|
165300
|
+
}
|
|
165301
|
+
parts.push({ text: ": " });
|
|
165302
|
+
visitForDisplayParts(member.type);
|
|
165303
|
+
break;
|
|
165304
|
+
case 190 /* OptionalType */:
|
|
165305
|
+
visitForDisplayParts(node.type);
|
|
165306
|
+
parts.push({ text: "?" });
|
|
165307
|
+
break;
|
|
165308
|
+
case 191 /* RestType */:
|
|
165309
|
+
parts.push({ text: "..." });
|
|
165310
|
+
visitForDisplayParts(node.type);
|
|
165311
|
+
break;
|
|
165312
|
+
case 192 /* UnionType */:
|
|
165313
|
+
visitDisplayPartList(node.types, " | ");
|
|
165314
|
+
break;
|
|
165315
|
+
case 193 /* IntersectionType */:
|
|
165316
|
+
visitDisplayPartList(node.types, " & ");
|
|
165317
|
+
break;
|
|
165318
|
+
case 194 /* ConditionalType */:
|
|
165319
|
+
const conditionalType = node;
|
|
165320
|
+
visitForDisplayParts(conditionalType.checkType);
|
|
165321
|
+
parts.push({ text: " extends " });
|
|
165322
|
+
visitForDisplayParts(conditionalType.extendsType);
|
|
165323
|
+
parts.push({ text: " ? " });
|
|
165324
|
+
visitForDisplayParts(conditionalType.trueType);
|
|
165325
|
+
parts.push({ text: " : " });
|
|
165326
|
+
visitForDisplayParts(conditionalType.falseType);
|
|
165327
|
+
break;
|
|
165328
|
+
case 195 /* InferType */:
|
|
165329
|
+
parts.push({ text: "infer " });
|
|
165330
|
+
visitForDisplayParts(node.typeParameter);
|
|
165331
|
+
break;
|
|
165332
|
+
case 196 /* ParenthesizedType */:
|
|
165333
|
+
parts.push({ text: "(" });
|
|
165334
|
+
visitForDisplayParts(node.type);
|
|
165335
|
+
parts.push({ text: ")" });
|
|
165336
|
+
break;
|
|
165337
|
+
case 198 /* TypeOperator */:
|
|
165338
|
+
const typeOperator = node;
|
|
165339
|
+
parts.push({ text: `${tokenToString(typeOperator.operator)} ` });
|
|
165340
|
+
visitForDisplayParts(typeOperator.type);
|
|
165341
|
+
break;
|
|
165342
|
+
case 199 /* IndexedAccessType */:
|
|
165343
|
+
const indexedAccess = node;
|
|
165344
|
+
visitForDisplayParts(indexedAccess.objectType);
|
|
165345
|
+
parts.push({ text: "[" });
|
|
165346
|
+
visitForDisplayParts(indexedAccess.indexType);
|
|
165347
|
+
parts.push({ text: "]" });
|
|
165348
|
+
break;
|
|
165349
|
+
case 200 /* MappedType */:
|
|
165350
|
+
const mappedType = node;
|
|
165351
|
+
parts.push({ text: "{ " });
|
|
165352
|
+
if (mappedType.readonlyToken) {
|
|
165353
|
+
if (mappedType.readonlyToken.kind === 40 /* PlusToken */) {
|
|
165354
|
+
parts.push({ text: "+" });
|
|
165355
|
+
} else if (mappedType.readonlyToken.kind === 41 /* MinusToken */) {
|
|
165356
|
+
parts.push({ text: "-" });
|
|
165357
|
+
}
|
|
165358
|
+
parts.push({ text: "readonly " });
|
|
165359
|
+
}
|
|
165360
|
+
parts.push({ text: "[" });
|
|
165361
|
+
visitForDisplayParts(mappedType.typeParameter);
|
|
165362
|
+
if (mappedType.nameType) {
|
|
165363
|
+
parts.push({ text: " as " });
|
|
165364
|
+
visitForDisplayParts(mappedType.nameType);
|
|
165365
|
+
}
|
|
165366
|
+
parts.push({ text: "]" });
|
|
165367
|
+
if (mappedType.questionToken) {
|
|
165368
|
+
if (mappedType.questionToken.kind === 40 /* PlusToken */) {
|
|
165369
|
+
parts.push({ text: "+" });
|
|
165370
|
+
} else if (mappedType.questionToken.kind === 41 /* MinusToken */) {
|
|
165371
|
+
parts.push({ text: "-" });
|
|
165372
|
+
}
|
|
165373
|
+
parts.push({ text: "?" });
|
|
165374
|
+
}
|
|
165375
|
+
parts.push({ text: ": " });
|
|
165376
|
+
if (mappedType.type) {
|
|
165377
|
+
visitForDisplayParts(mappedType.type);
|
|
165378
|
+
}
|
|
165379
|
+
parts.push({ text: "; }" });
|
|
165380
|
+
break;
|
|
165381
|
+
case 201 /* LiteralType */:
|
|
165382
|
+
visitForDisplayParts(node.literal);
|
|
165383
|
+
break;
|
|
165384
|
+
case 184 /* FunctionType */:
|
|
165385
|
+
const functionType = node;
|
|
165386
|
+
if (functionType.typeParameters) {
|
|
165387
|
+
parts.push({ text: "<" });
|
|
165388
|
+
visitDisplayPartList(functionType.typeParameters, ", ");
|
|
165389
|
+
parts.push({ text: ">" });
|
|
165390
|
+
}
|
|
165391
|
+
parts.push({ text: "(" });
|
|
165392
|
+
visitDisplayPartList(functionType.parameters, ", ");
|
|
165393
|
+
parts.push({ text: ")" });
|
|
165394
|
+
parts.push({ text: " => " });
|
|
165395
|
+
visitForDisplayParts(functionType.type);
|
|
165396
|
+
break;
|
|
165397
|
+
case 205 /* ImportType */:
|
|
165398
|
+
const importType = node;
|
|
165399
|
+
if (importType.isTypeOf) {
|
|
165400
|
+
parts.push({ text: "typeof " });
|
|
165401
|
+
}
|
|
165402
|
+
parts.push({ text: "import(" });
|
|
165403
|
+
visitForDisplayParts(importType.argument);
|
|
165404
|
+
if (importType.assertions) {
|
|
165405
|
+
parts.push({ text: ", { assert: " });
|
|
165406
|
+
visitDisplayPartList(importType.assertions.assertClause.elements, ", ");
|
|
165407
|
+
parts.push({ text: " }" });
|
|
165408
|
+
}
|
|
165409
|
+
parts.push({ text: ")" });
|
|
165410
|
+
if (importType.qualifier) {
|
|
165411
|
+
parts.push({ text: "." });
|
|
165412
|
+
visitForDisplayParts(importType.qualifier);
|
|
165413
|
+
}
|
|
165414
|
+
if (importType.typeArguments) {
|
|
165415
|
+
parts.push({ text: "<" });
|
|
165416
|
+
visitDisplayPartList(importType.typeArguments, ", ");
|
|
165417
|
+
parts.push({ text: ">" });
|
|
165418
|
+
}
|
|
165419
|
+
break;
|
|
165420
|
+
case 171 /* PropertySignature */:
|
|
165421
|
+
const propertySignature = node;
|
|
165422
|
+
if (propertySignature.modifiers) {
|
|
165423
|
+
visitDisplayPartList(propertySignature.modifiers, " ");
|
|
165424
|
+
}
|
|
165425
|
+
visitForDisplayParts(propertySignature.name);
|
|
165426
|
+
if (propertySignature.questionToken) {
|
|
165427
|
+
parts.push({ text: "?" });
|
|
165428
|
+
}
|
|
165429
|
+
if (propertySignature.type) {
|
|
165430
|
+
parts.push({ text: ": " });
|
|
165431
|
+
visitForDisplayParts(propertySignature.type);
|
|
165432
|
+
}
|
|
165433
|
+
break;
|
|
165434
|
+
default:
|
|
165435
|
+
Debug.failBadSyntaxKind(node);
|
|
165436
|
+
}
|
|
165437
|
+
}
|
|
165438
|
+
function visitDisplayPartList(nodes, separator) {
|
|
165439
|
+
nodes.forEach((node, index) => {
|
|
165440
|
+
if (index > 0) {
|
|
165441
|
+
parts.push({ text: separator });
|
|
165442
|
+
}
|
|
165443
|
+
visitForDisplayParts(node);
|
|
165444
|
+
});
|
|
165445
|
+
}
|
|
165446
|
+
}
|
|
165165
165447
|
function isUndefined(name) {
|
|
165166
165448
|
return name === "undefined";
|
|
165167
165449
|
}
|
|
@@ -165327,6 +165609,11 @@ function getJsDocTagsFromDeclarations(declarations, checker) {
|
|
|
165327
165609
|
}
|
|
165328
165610
|
for (const tag of tags) {
|
|
165329
165611
|
infos.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) });
|
|
165612
|
+
if (isJSDocPropertyLikeTag(tag) && tag.isNameFirst && tag.typeExpression && isJSDocTypeLiteral(tag.typeExpression.type)) {
|
|
165613
|
+
forEach(tag.typeExpression.type.jsDocPropertyTags, (propTag) => {
|
|
165614
|
+
infos.push({ name: propTag.tagName.text, text: getCommentDisplayParts(propTag, checker) });
|
|
165615
|
+
});
|
|
165616
|
+
}
|
|
165330
165617
|
}
|
|
165331
165618
|
});
|
|
165332
165619
|
return infos;
|
|
@@ -173162,8 +173449,6 @@ __export(ts_exports2, {
|
|
|
173162
173449
|
getResolvePackageJsonExports: () => getResolvePackageJsonExports,
|
|
173163
173450
|
getResolvePackageJsonImports: () => getResolvePackageJsonImports,
|
|
173164
173451
|
getResolvedExternalModuleName: () => getResolvedExternalModuleName,
|
|
173165
|
-
getResolvedModule: () => getResolvedModule,
|
|
173166
|
-
getResolvedTypeReferenceDirective: () => getResolvedTypeReferenceDirective,
|
|
173167
173452
|
getRestIndicatorOfBindingOrAssignmentElement: () => getRestIndicatorOfBindingOrAssignmentElement,
|
|
173168
173453
|
getRestParameterElementType: () => getRestParameterElementType,
|
|
173169
173454
|
getRightMostAssignedExpression: () => getRightMostAssignedExpression,
|
|
@@ -174261,8 +174546,6 @@ __export(ts_exports2, {
|
|
|
174261
174546
|
setParent: () => setParent,
|
|
174262
174547
|
setParentRecursive: () => setParentRecursive,
|
|
174263
174548
|
setPrivateIdentifier: () => setPrivateIdentifier,
|
|
174264
|
-
setResolvedModule: () => setResolvedModule,
|
|
174265
|
-
setResolvedTypeReferenceDirective: () => setResolvedTypeReferenceDirective,
|
|
174266
174549
|
setSnippetElement: () => setSnippetElement,
|
|
174267
174550
|
setSourceMapRange: () => setSourceMapRange,
|
|
174268
174551
|
setStackTraceLimit: () => setStackTraceLimit,
|
|
@@ -174489,7 +174772,6 @@ __export(ts_exports2, {
|
|
|
174489
174772
|
writeCommentRange: () => writeCommentRange,
|
|
174490
174773
|
writeFile: () => writeFile,
|
|
174491
174774
|
writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
|
|
174492
|
-
zipToModeAwareCache: () => zipToModeAwareCache,
|
|
174493
174775
|
zipWith: () => zipWith
|
|
174494
174776
|
});
|
|
174495
174777
|
|
|
@@ -176363,7 +176645,8 @@ var Project3 = class _Project {
|
|
|
176363
176645
|
}
|
|
176364
176646
|
if (this.program && !this.symlinks.hasProcessedResolutions()) {
|
|
176365
176647
|
this.symlinks.setSymlinksFromResolutions(
|
|
176366
|
-
this.program.
|
|
176648
|
+
this.program.resolvedModules,
|
|
176649
|
+
this.program.resolvedTypeReferenceDirectiveNames,
|
|
176367
176650
|
this.program.getAutomaticTypeDirectiveResolutions()
|
|
176368
176651
|
);
|
|
176369
176652
|
}
|
|
@@ -177768,16 +178051,23 @@ function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) {
|
|
|
177768
178051
|
const sourceFiles = program.getSourceFiles();
|
|
177769
178052
|
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "getUnresolvedImports", { count: sourceFiles.length });
|
|
177770
178053
|
const ambientModules = program.getTypeChecker().getAmbientModules().map((mod) => stripQuotes(mod.getName()));
|
|
177771
|
-
const result = sortAndDeduplicate(flatMap(sourceFiles, (sourceFile) => extractUnresolvedImportsFromSourceFile(
|
|
178054
|
+
const result = sortAndDeduplicate(flatMap(sourceFiles, (sourceFile) => extractUnresolvedImportsFromSourceFile(
|
|
178055
|
+
program,
|
|
178056
|
+
sourceFile,
|
|
178057
|
+
ambientModules,
|
|
178058
|
+
cachedUnresolvedImportsPerFile
|
|
178059
|
+
)));
|
|
177772
178060
|
(_b = tracing) == null ? void 0 : _b.pop();
|
|
177773
178061
|
return result;
|
|
177774
178062
|
}
|
|
177775
|
-
function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) {
|
|
178063
|
+
function extractUnresolvedImportsFromSourceFile(program, file, ambientModules, cachedUnresolvedImportsPerFile) {
|
|
177776
178064
|
return getOrUpdate(cachedUnresolvedImportsPerFile, file.path, () => {
|
|
177777
|
-
|
|
178065
|
+
var _a;
|
|
178066
|
+
const resolvedModules = (_a = program.resolvedModules) == null ? void 0 : _a.get(file.path);
|
|
178067
|
+
if (!resolvedModules)
|
|
177778
178068
|
return emptyArray2;
|
|
177779
178069
|
let unresolvedImports;
|
|
177780
|
-
|
|
178070
|
+
resolvedModules.forEach(({ resolvedModule }, name) => {
|
|
177781
178071
|
if ((!resolvedModule || !resolutionExtensionIsTSOrJson(resolvedModule.extension)) && !isExternalModuleNameRelative(name) && !ambientModules.some((m) => m === name)) {
|
|
177782
178072
|
unresolvedImports = append(unresolvedImports, parsePackageName(name).packageName);
|
|
177783
178073
|
}
|
|
@@ -187724,8 +188014,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
187724
188014
|
getResolvePackageJsonExports,
|
|
187725
188015
|
getResolvePackageJsonImports,
|
|
187726
188016
|
getResolvedExternalModuleName,
|
|
187727
|
-
getResolvedModule,
|
|
187728
|
-
getResolvedTypeReferenceDirective,
|
|
187729
188017
|
getRestIndicatorOfBindingOrAssignmentElement,
|
|
187730
188018
|
getRestParameterElementType,
|
|
187731
188019
|
getRightMostAssignedExpression,
|
|
@@ -188823,8 +189111,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188823
189111
|
setParent,
|
|
188824
189112
|
setParentRecursive,
|
|
188825
189113
|
setPrivateIdentifier,
|
|
188826
|
-
setResolvedModule,
|
|
188827
|
-
setResolvedTypeReferenceDirective,
|
|
188828
189114
|
setSnippetElement,
|
|
188829
189115
|
setSourceMapRange,
|
|
188830
189116
|
setStackTraceLimit,
|
|
@@ -189051,7 +189337,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189051
189337
|
writeCommentRange,
|
|
189052
189338
|
writeFile,
|
|
189053
189339
|
writeFileEnsuringDirectories,
|
|
189054
|
-
zipToModeAwareCache,
|
|
189055
189340
|
zipWith
|
|
189056
189341
|
});
|
|
189057
189342
|
//# sourceMappingURL=tsserver.js.map
|