typescript 5.0.0-dev.20221205 → 5.0.0-dev.20221207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +592 -435
- package/lib/tsserver.js +153270 -150849
- package/lib/tsserverlibrary.d.ts +46 -24
- package/lib/tsserverlibrary.js +683 -493
- package/lib/typescript.d.ts +46 -21
- package/lib/typescript.js +662 -476
- package/lib/typingsInstaller.js +72 -77
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -42,7 +42,7 @@ var ts = (() => {
|
|
|
42
42
|
"src/compiler/corePublic.ts"() {
|
|
43
43
|
"use strict";
|
|
44
44
|
versionMajorMinor = "5.0";
|
|
45
|
-
version = `${versionMajorMinor}.0-dev.
|
|
45
|
+
version = `${versionMajorMinor}.0-dev.20221207`;
|
|
46
46
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
47
47
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
48
48
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -2190,22 +2190,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
2190
2190
|
function enableDebugInfo() {
|
|
2191
2191
|
if (isDebugInfoEnabled)
|
|
2192
2192
|
return;
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
function getWeakTypeTextMap() {
|
|
2196
|
-
if (weakTypeTextMap === void 0) {
|
|
2197
|
-
if (typeof WeakMap === "function")
|
|
2198
|
-
weakTypeTextMap = /* @__PURE__ */ new WeakMap();
|
|
2199
|
-
}
|
|
2200
|
-
return weakTypeTextMap;
|
|
2201
|
-
}
|
|
2202
|
-
function getWeakNodeTextMap() {
|
|
2203
|
-
if (weakNodeTextMap === void 0) {
|
|
2204
|
-
if (typeof WeakMap === "function")
|
|
2205
|
-
weakNodeTextMap = /* @__PURE__ */ new WeakMap();
|
|
2206
|
-
}
|
|
2207
|
-
return weakNodeTextMap;
|
|
2208
|
-
}
|
|
2193
|
+
const weakTypeTextMap = /* @__PURE__ */ new WeakMap();
|
|
2194
|
+
const weakNodeTextMap = /* @__PURE__ */ new WeakMap();
|
|
2209
2195
|
Object.defineProperties(objectAllocator.getSymbolConstructor().prototype, {
|
|
2210
2196
|
__tsDebuggerDisplay: {
|
|
2211
2197
|
value() {
|
|
@@ -2234,11 +2220,10 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
2234
2220
|
} },
|
|
2235
2221
|
__debugTypeToString: {
|
|
2236
2222
|
value() {
|
|
2237
|
-
|
|
2238
|
-
let text = map2 == null ? void 0 : map2.get(this);
|
|
2223
|
+
let text = weakTypeTextMap.get(this);
|
|
2239
2224
|
if (text === void 0) {
|
|
2240
2225
|
text = this.checker.typeToString(this);
|
|
2241
|
-
|
|
2226
|
+
weakTypeTextMap.set(this, text);
|
|
2242
2227
|
}
|
|
2243
2228
|
return text;
|
|
2244
2229
|
}
|
|
@@ -2290,13 +2275,12 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
2290
2275
|
value(includeTrivia) {
|
|
2291
2276
|
if (nodeIsSynthesized(this))
|
|
2292
2277
|
return "";
|
|
2293
|
-
|
|
2294
|
-
let text = map2 == null ? void 0 : map2.get(this);
|
|
2278
|
+
let text = weakNodeTextMap.get(this);
|
|
2295
2279
|
if (text === void 0) {
|
|
2296
2280
|
const parseNode = getParseTreeNode(this);
|
|
2297
2281
|
const sourceFile = parseNode && getSourceFileOfNode(parseNode);
|
|
2298
2282
|
text = sourceFile ? getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
|
|
2299
|
-
|
|
2283
|
+
weakNodeTextMap.set(this, text);
|
|
2300
2284
|
}
|
|
2301
2285
|
return text;
|
|
2302
2286
|
}
|
|
@@ -4097,6 +4081,7 @@ ${lanes.join("\n")}
|
|
|
4097
4081
|
FilePreprocessingDiagnosticsKind = /* @__PURE__ */ ((FilePreprocessingDiagnosticsKind2) => {
|
|
4098
4082
|
FilePreprocessingDiagnosticsKind2[FilePreprocessingDiagnosticsKind2["FilePreprocessingReferencedDiagnostic"] = 0] = "FilePreprocessingReferencedDiagnostic";
|
|
4099
4083
|
FilePreprocessingDiagnosticsKind2[FilePreprocessingDiagnosticsKind2["FilePreprocessingFileExplainingDiagnostic"] = 1] = "FilePreprocessingFileExplainingDiagnostic";
|
|
4084
|
+
FilePreprocessingDiagnosticsKind2[FilePreprocessingDiagnosticsKind2["ResolutionDiagnostics"] = 2] = "ResolutionDiagnostics";
|
|
4100
4085
|
return FilePreprocessingDiagnosticsKind2;
|
|
4101
4086
|
})(FilePreprocessingDiagnosticsKind || {});
|
|
4102
4087
|
EmitOnly = /* @__PURE__ */ ((EmitOnly4) => {
|
|
@@ -12244,7 +12229,8 @@ ${lanes.join("\n")}
|
|
|
12244
12229
|
return node.end - node.pos;
|
|
12245
12230
|
}
|
|
12246
12231
|
function getResolvedModule(sourceFile, moduleNameText, mode) {
|
|
12247
|
-
|
|
12232
|
+
var _a2, _b;
|
|
12233
|
+
return (_b = (_a2 = sourceFile == null ? void 0 : sourceFile.resolvedModules) == null ? void 0 : _a2.get(moduleNameText, mode)) == null ? void 0 : _b.resolvedModule;
|
|
12248
12234
|
}
|
|
12249
12235
|
function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
|
|
12250
12236
|
if (!sourceFile.resolvedModules) {
|
|
@@ -12259,14 +12245,14 @@ ${lanes.join("\n")}
|
|
|
12259
12245
|
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
|
|
12260
12246
|
}
|
|
12261
12247
|
function getResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, mode) {
|
|
12262
|
-
var _a2;
|
|
12263
|
-
return (_a2 = sourceFile == null ? void 0 : sourceFile.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _a2.get(typeReferenceDirectiveName, mode);
|
|
12248
|
+
var _a2, _b;
|
|
12249
|
+
return (_b = (_a2 = sourceFile == null ? void 0 : sourceFile.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _a2.get(typeReferenceDirectiveName, mode)) == null ? void 0 : _b.resolvedTypeReferenceDirective;
|
|
12264
12250
|
}
|
|
12265
12251
|
function projectReferenceIsEqualTo(oldRef, newRef) {
|
|
12266
12252
|
return oldRef.path === newRef.path && !oldRef.prepend === !newRef.prepend && !oldRef.circular === !newRef.circular;
|
|
12267
12253
|
}
|
|
12268
12254
|
function moduleResolutionIsEqualTo(oldResolution, newResolution) {
|
|
12269
|
-
return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.originalPath === newResolution.originalPath && packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
|
|
12255
|
+
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);
|
|
12270
12256
|
}
|
|
12271
12257
|
function packageIdIsEqual(a, b) {
|
|
12272
12258
|
return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
|
|
@@ -12278,15 +12264,15 @@ ${lanes.join("\n")}
|
|
|
12278
12264
|
return `${packageIdToPackageName(packageId)}@${packageId.version}`;
|
|
12279
12265
|
}
|
|
12280
12266
|
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
|
|
12281
|
-
return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary && oldResolution.originalPath === newResolution.originalPath;
|
|
12267
|
+
return oldResolution === newResolution || oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective || !!oldResolution.resolvedTypeReferenceDirective && !!newResolution.resolvedTypeReferenceDirective && oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName && !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary && oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
|
|
12282
12268
|
}
|
|
12283
|
-
function hasChangesInResolutions(names, newSourceFile, newResolutions, oldResolutions, comparer) {
|
|
12269
|
+
function hasChangesInResolutions(names, newSourceFile, newResolutions, oldResolutions, comparer, nameAndModeGetter) {
|
|
12284
12270
|
Debug.assert(names.length === newResolutions.length);
|
|
12285
12271
|
for (let i = 0; i < names.length; i++) {
|
|
12286
12272
|
const newResolution = newResolutions[i];
|
|
12287
12273
|
const entry = names[i];
|
|
12288
|
-
const name =
|
|
12289
|
-
const mode =
|
|
12274
|
+
const name = nameAndModeGetter.getName(entry);
|
|
12275
|
+
const mode = nameAndModeGetter.getMode(entry, newSourceFile);
|
|
12290
12276
|
const oldResolution = oldResolutions && oldResolutions.get(name, mode);
|
|
12291
12277
|
const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution;
|
|
12292
12278
|
if (changed) {
|
|
@@ -16635,13 +16621,14 @@ ${lanes.join("\n")}
|
|
|
16635
16621
|
}
|
|
16636
16622
|
},
|
|
16637
16623
|
setSymlinksFromResolutions(files, typeReferenceDirectives) {
|
|
16638
|
-
var _a2;
|
|
16624
|
+
var _a2, _b;
|
|
16639
16625
|
Debug.assert(!hasProcessedResolutions);
|
|
16640
16626
|
hasProcessedResolutions = true;
|
|
16641
16627
|
for (const file of files) {
|
|
16642
|
-
(_a2 = file.resolvedModules) == null ? void 0 : _a2.forEach((resolution) => processResolution(this, resolution));
|
|
16628
|
+
(_a2 = file.resolvedModules) == null ? void 0 : _a2.forEach((resolution) => processResolution(this, resolution.resolvedModule));
|
|
16629
|
+
(_b = file.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _b.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
|
|
16643
16630
|
}
|
|
16644
|
-
typeReferenceDirectives
|
|
16631
|
+
typeReferenceDirectives.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
|
|
16645
16632
|
},
|
|
16646
16633
|
hasProcessedResolutions: () => hasProcessedResolutions
|
|
16647
16634
|
};
|
|
@@ -34981,17 +34968,29 @@ ${lanes.join("\n")}
|
|
|
34981
34968
|
}
|
|
34982
34969
|
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
|
|
34983
34970
|
if (resultFromCache) {
|
|
34984
|
-
resultFromCache.failedLookupLocations.
|
|
34985
|
-
resultFromCache.affectingLocations.
|
|
34971
|
+
resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
|
|
34972
|
+
resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
|
|
34973
|
+
resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
|
|
34986
34974
|
return resultFromCache;
|
|
34987
34975
|
}
|
|
34988
34976
|
return {
|
|
34989
34977
|
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? void 0 : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport, packageId: resolved.packageId },
|
|
34990
|
-
failedLookupLocations,
|
|
34991
|
-
affectingLocations,
|
|
34992
|
-
resolutionDiagnostics: diagnostics
|
|
34978
|
+
failedLookupLocations: initializeResolutionField(failedLookupLocations),
|
|
34979
|
+
affectingLocations: initializeResolutionField(affectingLocations),
|
|
34980
|
+
resolutionDiagnostics: initializeResolutionField(diagnostics)
|
|
34993
34981
|
};
|
|
34994
34982
|
}
|
|
34983
|
+
function initializeResolutionField(value) {
|
|
34984
|
+
return value.length ? value : void 0;
|
|
34985
|
+
}
|
|
34986
|
+
function updateResolutionField(to, value) {
|
|
34987
|
+
if (!(value == null ? void 0 : value.length))
|
|
34988
|
+
return to;
|
|
34989
|
+
if (!(to == null ? void 0 : to.length))
|
|
34990
|
+
return value;
|
|
34991
|
+
to.push(...value);
|
|
34992
|
+
return to;
|
|
34993
|
+
}
|
|
34995
34994
|
function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
|
|
34996
34995
|
if (!hasProperty(jsonContent, fieldName)) {
|
|
34997
34996
|
if (state.traceEnabled) {
|
|
@@ -35124,8 +35123,10 @@ ${lanes.join("\n")}
|
|
|
35124
35123
|
options = redirectedReference.commandLine.options;
|
|
35125
35124
|
}
|
|
35126
35125
|
const containingDirectory = containingFile ? getDirectoryPath(containingFile) : void 0;
|
|
35127
|
-
|
|
35128
|
-
|
|
35126
|
+
let result = containingDirectory ? cache == null ? void 0 : cache.getFromDirectoryCache(typeReferenceDirectiveName, resolutionMode, containingDirectory, redirectedReference) : void 0;
|
|
35127
|
+
if (!result && containingDirectory && !isExternalModuleNameRelative(typeReferenceDirectiveName)) {
|
|
35128
|
+
result = cache == null ? void 0 : cache.getFromNonRelativeNameCache(typeReferenceDirectiveName, resolutionMode, containingDirectory, redirectedReference);
|
|
35129
|
+
}
|
|
35129
35130
|
if (result) {
|
|
35130
35131
|
if (traceEnabled) {
|
|
35131
35132
|
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -35195,8 +35196,18 @@ ${lanes.join("\n")}
|
|
|
35195
35196
|
isExternalLibraryImport: pathContainsNodeModules(fileName)
|
|
35196
35197
|
};
|
|
35197
35198
|
}
|
|
35198
|
-
result = {
|
|
35199
|
-
|
|
35199
|
+
result = {
|
|
35200
|
+
resolvedTypeReferenceDirective,
|
|
35201
|
+
failedLookupLocations: initializeResolutionField(failedLookupLocations),
|
|
35202
|
+
affectingLocations: initializeResolutionField(affectingLocations),
|
|
35203
|
+
resolutionDiagnostics: initializeResolutionField(diagnostics)
|
|
35204
|
+
};
|
|
35205
|
+
if (containingDirectory) {
|
|
35206
|
+
cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
|
|
35207
|
+
if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
|
|
35208
|
+
cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
35209
|
+
}
|
|
35210
|
+
}
|
|
35200
35211
|
if (traceEnabled)
|
|
35201
35212
|
traceResult(result);
|
|
35202
35213
|
return result;
|
|
@@ -35326,23 +35337,27 @@ ${lanes.join("\n")}
|
|
|
35326
35337
|
if (ownOptions)
|
|
35327
35338
|
redirectsMap.set(ownOptions, ownMap);
|
|
35328
35339
|
return {
|
|
35340
|
+
getMapOfCacheRedirects,
|
|
35329
35341
|
getOrCreateMapOfCacheRedirects,
|
|
35330
35342
|
update,
|
|
35331
35343
|
clear: clear2
|
|
35332
35344
|
};
|
|
35345
|
+
function getMapOfCacheRedirects(redirectedReference) {
|
|
35346
|
+
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, false) : ownMap;
|
|
35347
|
+
}
|
|
35333
35348
|
function getOrCreateMapOfCacheRedirects(redirectedReference) {
|
|
35334
|
-
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options) : ownMap;
|
|
35349
|
+
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, true) : ownMap;
|
|
35335
35350
|
}
|
|
35336
35351
|
function update(newOptions) {
|
|
35337
35352
|
if (ownOptions !== newOptions) {
|
|
35338
35353
|
if (ownOptions)
|
|
35339
|
-
ownMap = getOrCreateMap(newOptions);
|
|
35354
|
+
ownMap = getOrCreateMap(newOptions, true);
|
|
35340
35355
|
else
|
|
35341
35356
|
redirectsMap.set(newOptions, ownMap);
|
|
35342
35357
|
ownOptions = newOptions;
|
|
35343
35358
|
}
|
|
35344
35359
|
}
|
|
35345
|
-
function getOrCreateMap(redirectOptions) {
|
|
35360
|
+
function getOrCreateMap(redirectOptions, create) {
|
|
35346
35361
|
let result = redirectsMap.get(redirectOptions);
|
|
35347
35362
|
if (result)
|
|
35348
35363
|
return result;
|
|
@@ -35356,9 +35371,13 @@ ${lanes.join("\n")}
|
|
|
35356
35371
|
else if (!redirectsKeyToMap.has(ownKey))
|
|
35357
35372
|
redirectsKeyToMap.set(ownKey, ownMap);
|
|
35358
35373
|
}
|
|
35359
|
-
|
|
35374
|
+
if (create)
|
|
35375
|
+
result != null ? result : result = /* @__PURE__ */ new Map();
|
|
35376
|
+
if (result)
|
|
35377
|
+
redirectsKeyToMap.set(key, result);
|
|
35360
35378
|
}
|
|
35361
|
-
|
|
35379
|
+
if (result)
|
|
35380
|
+
redirectsMap.set(redirectOptions, result);
|
|
35362
35381
|
return result;
|
|
35363
35382
|
}
|
|
35364
35383
|
function clear2() {
|
|
@@ -35410,8 +35429,10 @@ ${lanes.join("\n")}
|
|
|
35410
35429
|
}
|
|
35411
35430
|
return result;
|
|
35412
35431
|
}
|
|
35413
|
-
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName,
|
|
35432
|
+
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
|
|
35433
|
+
const directoryToModuleNameMap = createCacheWithRedirects(options);
|
|
35414
35434
|
return {
|
|
35435
|
+
getFromDirectoryCache,
|
|
35415
35436
|
getOrCreateCacheForDirectory,
|
|
35416
35437
|
clear: clear2,
|
|
35417
35438
|
update
|
|
@@ -35419,13 +35440,18 @@ ${lanes.join("\n")}
|
|
|
35419
35440
|
function clear2() {
|
|
35420
35441
|
directoryToModuleNameMap.clear();
|
|
35421
35442
|
}
|
|
35422
|
-
function update(
|
|
35423
|
-
directoryToModuleNameMap.update(
|
|
35443
|
+
function update(options2) {
|
|
35444
|
+
directoryToModuleNameMap.update(options2);
|
|
35424
35445
|
}
|
|
35425
35446
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
35426
35447
|
const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
35427
35448
|
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
|
|
35428
35449
|
}
|
|
35450
|
+
function getFromDirectoryCache(name, mode, directoryName, redirectedReference) {
|
|
35451
|
+
var _a2, _b;
|
|
35452
|
+
const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
35453
|
+
return (_b = (_a2 = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a2.get(path)) == null ? void 0 : _b.get(name, mode);
|
|
35454
|
+
}
|
|
35429
35455
|
}
|
|
35430
35456
|
function createModeAwareCacheKey(specifier, mode) {
|
|
35431
35457
|
return mode === void 0 ? specifier : `${mode}|${specifier}`;
|
|
@@ -35465,48 +35491,41 @@ ${lanes.join("\n")}
|
|
|
35465
35491
|
return result;
|
|
35466
35492
|
}
|
|
35467
35493
|
}
|
|
35468
|
-
function
|
|
35469
|
-
return !isString(entry) ? isStringLiteralLike(entry) ? entry.text : toFileNameLowerCase(entry.fileName) : entry;
|
|
35470
|
-
}
|
|
35471
|
-
function getResolutionMode(entry, file) {
|
|
35472
|
-
return isStringLiteralLike(entry) ? getModeForUsageLocation(file, entry) : entry.resolutionMode || file.impliedNodeFormat;
|
|
35473
|
-
}
|
|
35474
|
-
function zipToModeAwareCache(file, keys, values) {
|
|
35494
|
+
function zipToModeAwareCache(file, keys, values, nameAndModeGetter) {
|
|
35475
35495
|
Debug.assert(keys.length === values.length);
|
|
35476
35496
|
const map2 = createModeAwareCache();
|
|
35477
35497
|
for (let i = 0; i < keys.length; ++i) {
|
|
35478
35498
|
const entry = keys[i];
|
|
35479
|
-
map2.set(
|
|
35499
|
+
map2.set(nameAndModeGetter.getName(entry), nameAndModeGetter.getMode(entry, file), values[i]);
|
|
35480
35500
|
}
|
|
35481
35501
|
return map2;
|
|
35482
35502
|
}
|
|
35483
|
-
function
|
|
35484
|
-
|
|
35485
|
-
|
|
35503
|
+
function getOriginalOrResolvedModuleFileName(result) {
|
|
35504
|
+
return result.resolvedModule && (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
|
|
35505
|
+
}
|
|
35506
|
+
function getOriginalOrResolvedTypeReferenceFileName(result) {
|
|
35507
|
+
return result.resolvedTypeReferenceDirective && (result.resolvedTypeReferenceDirective.originalPath || result.resolvedTypeReferenceDirective.resolvedFileName);
|
|
35508
|
+
}
|
|
35509
|
+
function createNonRelativeNameResolutionCache(currentDirectory, getCanonicalFileName, options, getResolvedFileName) {
|
|
35486
35510
|
const moduleNameToDirectoryMap = createCacheWithRedirects(options);
|
|
35487
|
-
const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
35488
35511
|
return {
|
|
35489
|
-
|
|
35490
|
-
|
|
35491
|
-
getOrCreateCacheForModuleName,
|
|
35512
|
+
getFromNonRelativeNameCache,
|
|
35513
|
+
getOrCreateCacheForNonRelativeName,
|
|
35492
35514
|
clear: clear2,
|
|
35493
|
-
update
|
|
35494
|
-
getPackageJsonInfoCache: () => packageJsonInfoCache,
|
|
35495
|
-
clearAllExceptPackageJsonInfoCache
|
|
35515
|
+
update
|
|
35496
35516
|
};
|
|
35497
35517
|
function clear2() {
|
|
35498
|
-
clearAllExceptPackageJsonInfoCache();
|
|
35499
|
-
packageJsonInfoCache.clear();
|
|
35500
|
-
}
|
|
35501
|
-
function clearAllExceptPackageJsonInfoCache() {
|
|
35502
|
-
perDirectoryResolutionCache.clear();
|
|
35503
35518
|
moduleNameToDirectoryMap.clear();
|
|
35504
35519
|
}
|
|
35505
35520
|
function update(options2) {
|
|
35506
|
-
directoryToModuleNameMap.update(options2);
|
|
35507
35521
|
moduleNameToDirectoryMap.update(options2);
|
|
35508
35522
|
}
|
|
35509
|
-
function
|
|
35523
|
+
function getFromNonRelativeNameCache(nonRelativeModuleName, mode, directoryName, redirectedReference) {
|
|
35524
|
+
var _a2, _b;
|
|
35525
|
+
Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
|
|
35526
|
+
return (_b = (_a2 = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a2.get(createModeAwareCacheKey(nonRelativeModuleName, mode))) == null ? void 0 : _b.get(directoryName);
|
|
35527
|
+
}
|
|
35528
|
+
function getOrCreateCacheForNonRelativeName(nonRelativeModuleName, mode, redirectedReference) {
|
|
35510
35529
|
Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
|
|
35511
35530
|
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
|
|
35512
35531
|
}
|
|
@@ -35522,7 +35541,7 @@ ${lanes.join("\n")}
|
|
|
35522
35541
|
return;
|
|
35523
35542
|
}
|
|
35524
35543
|
directoryPathMap.set(path, result);
|
|
35525
|
-
const resolvedFileName =
|
|
35544
|
+
const resolvedFileName = getResolvedFileName(result);
|
|
35526
35545
|
const commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
|
|
35527
35546
|
let current = path;
|
|
35528
35547
|
while (current !== commonPrefix) {
|
|
@@ -35556,14 +35575,22 @@ ${lanes.join("\n")}
|
|
|
35556
35575
|
}
|
|
35557
35576
|
}
|
|
35558
35577
|
}
|
|
35559
|
-
function
|
|
35560
|
-
const
|
|
35561
|
-
const
|
|
35562
|
-
|
|
35578
|
+
function createModuleOrTypeReferenceResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, getResolvedFileName) {
|
|
35579
|
+
const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
35580
|
+
const nonRelativeNameResolutionCache = createNonRelativeNameResolutionCache(
|
|
35581
|
+
currentDirectory,
|
|
35582
|
+
getCanonicalFileName,
|
|
35583
|
+
options,
|
|
35584
|
+
getResolvedFileName
|
|
35585
|
+
);
|
|
35586
|
+
packageJsonInfoCache != null ? packageJsonInfoCache : packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
35563
35587
|
return {
|
|
35564
35588
|
...packageJsonInfoCache,
|
|
35565
35589
|
...perDirectoryResolutionCache,
|
|
35590
|
+
...nonRelativeNameResolutionCache,
|
|
35566
35591
|
clear: clear2,
|
|
35592
|
+
update,
|
|
35593
|
+
getPackageJsonInfoCache: () => packageJsonInfoCache,
|
|
35567
35594
|
clearAllExceptPackageJsonInfoCache
|
|
35568
35595
|
};
|
|
35569
35596
|
function clear2() {
|
|
@@ -35572,14 +35599,36 @@ ${lanes.join("\n")}
|
|
|
35572
35599
|
}
|
|
35573
35600
|
function clearAllExceptPackageJsonInfoCache() {
|
|
35574
35601
|
perDirectoryResolutionCache.clear();
|
|
35602
|
+
nonRelativeNameResolutionCache.clear();
|
|
35575
35603
|
}
|
|
35604
|
+
function update(options2) {
|
|
35605
|
+
perDirectoryResolutionCache.update(options2);
|
|
35606
|
+
nonRelativeNameResolutionCache.update(options2);
|
|
35607
|
+
}
|
|
35608
|
+
}
|
|
35609
|
+
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
|
|
35610
|
+
const result = createModuleOrTypeReferenceResolutionCache(
|
|
35611
|
+
currentDirectory,
|
|
35612
|
+
getCanonicalFileName,
|
|
35613
|
+
options,
|
|
35614
|
+
void 0,
|
|
35615
|
+
getOriginalOrResolvedModuleFileName
|
|
35616
|
+
);
|
|
35617
|
+
result.getOrCreateCacheForModuleName = (nonRelativeName, mode, redirectedReference) => result.getOrCreateCacheForNonRelativeName(nonRelativeName, mode, redirectedReference);
|
|
35618
|
+
return result;
|
|
35619
|
+
}
|
|
35620
|
+
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
|
|
35621
|
+
return createModuleOrTypeReferenceResolutionCache(
|
|
35622
|
+
currentDirectory,
|
|
35623
|
+
getCanonicalFileName,
|
|
35624
|
+
options,
|
|
35625
|
+
packageJsonInfoCache,
|
|
35626
|
+
getOriginalOrResolvedTypeReferenceFileName
|
|
35627
|
+
);
|
|
35576
35628
|
}
|
|
35577
35629
|
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
35578
35630
|
const containingDirectory = getDirectoryPath(containingFile);
|
|
35579
|
-
|
|
35580
|
-
if (!perFolderCache)
|
|
35581
|
-
return void 0;
|
|
35582
|
-
return perFolderCache.get(moduleName, mode);
|
|
35631
|
+
return cache.getFromDirectoryCache(moduleName, mode, containingDirectory, void 0);
|
|
35583
35632
|
}
|
|
35584
35633
|
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
35585
35634
|
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
@@ -35593,8 +35642,7 @@ ${lanes.join("\n")}
|
|
|
35593
35642
|
}
|
|
35594
35643
|
}
|
|
35595
35644
|
const containingDirectory = getDirectoryPath(containingFile);
|
|
35596
|
-
|
|
35597
|
-
let result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
|
|
35645
|
+
let result = cache == null ? void 0 : cache.getFromDirectoryCache(moduleName, resolutionMode, containingDirectory, redirectedReference);
|
|
35598
35646
|
if (result) {
|
|
35599
35647
|
if (traceEnabled) {
|
|
35600
35648
|
trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -35644,11 +35692,9 @@ ${lanes.join("\n")}
|
|
|
35644
35692
|
if (result && result.resolvedModule)
|
|
35645
35693
|
perfLogger.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`);
|
|
35646
35694
|
perfLogger.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null");
|
|
35647
|
-
|
|
35648
|
-
|
|
35649
|
-
|
|
35650
|
-
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
35651
|
-
}
|
|
35695
|
+
cache == null ? void 0 : cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
|
|
35696
|
+
if (!isExternalModuleNameRelative(moduleName)) {
|
|
35697
|
+
cache == null ? void 0 : cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
35652
35698
|
}
|
|
35653
35699
|
}
|
|
35654
35700
|
if (traceEnabled) {
|
|
@@ -35765,7 +35811,7 @@ ${lanes.join("\n")}
|
|
|
35765
35811
|
function resolveJSModule(moduleName, initialDir, host) {
|
|
35766
35812
|
const { resolvedModule, failedLookupLocations } = tryResolveJSModuleWorker(moduleName, initialDir, host);
|
|
35767
35813
|
if (!resolvedModule) {
|
|
35768
|
-
throw new Error(`Could not resolve JS module '${moduleName}' starting at '${initialDir}'. Looked in: ${failedLookupLocations.join(", ")}`);
|
|
35814
|
+
throw new Error(`Could not resolve JS module '${moduleName}' starting at '${initialDir}'. Looked in: ${failedLookupLocations == null ? void 0 : failedLookupLocations.join(", ")}`);
|
|
35769
35815
|
}
|
|
35770
35816
|
return resolvedModule.resolvedFileName;
|
|
35771
35817
|
}
|
|
@@ -36627,7 +36673,7 @@ ${lanes.join("\n")}
|
|
|
36627
36673
|
return loadModuleFromNearestNodeModulesDirectoryWorker(4 /* Declaration */, moduleName, directory, state, true, void 0, void 0);
|
|
36628
36674
|
}
|
|
36629
36675
|
function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
36630
|
-
const
|
|
36676
|
+
const mode = state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */;
|
|
36631
36677
|
const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
|
|
36632
36678
|
const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
|
|
36633
36679
|
if (priorityExtensions) {
|
|
@@ -36641,7 +36687,7 @@ ${lanes.join("\n")}
|
|
|
36641
36687
|
function lookup(extensions2) {
|
|
36642
36688
|
return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
|
|
36643
36689
|
if (getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
36644
|
-
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
|
|
36690
|
+
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
|
|
36645
36691
|
if (resolutionFromCache) {
|
|
36646
36692
|
return resolutionFromCache;
|
|
36647
36693
|
}
|
|
@@ -36786,8 +36832,8 @@ ${lanes.join("\n")}
|
|
|
36786
36832
|
function unmangleScopedPackageName(typesPackageName) {
|
|
36787
36833
|
return stringContains(typesPackageName, mangledScopedPackageSeparator) ? "@" + typesPackageName.replace(mangledScopedPackageSeparator, directorySeparator) : typesPackageName;
|
|
36788
36834
|
}
|
|
36789
|
-
function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
|
|
36790
|
-
const result = cache && cache.
|
|
36835
|
+
function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
|
|
36836
|
+
const result = cache && cache.getFromNonRelativeNameCache(moduleName, mode, containingDirectory, redirectedReference);
|
|
36791
36837
|
if (result) {
|
|
36792
36838
|
if (state.traceEnabled) {
|
|
36793
36839
|
trace(state.host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -36830,9 +36876,8 @@ ${lanes.join("\n")}
|
|
|
36830
36876
|
return { value: resolvedUsingSettings };
|
|
36831
36877
|
}
|
|
36832
36878
|
if (!isExternalModuleNameRelative(moduleName)) {
|
|
36833
|
-
const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, void 0, redirectedReference);
|
|
36834
36879
|
const resolved2 = forEachAncestorDirectory(containingDirectory, (directory) => {
|
|
36835
|
-
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
|
|
36880
|
+
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, void 0, directory, redirectedReference, state);
|
|
36836
36881
|
if (resolutionFromCache) {
|
|
36837
36882
|
return resolutionFromCache;
|
|
36838
36883
|
}
|
|
@@ -40244,7 +40289,7 @@ ${lanes.join("\n")}
|
|
|
40244
40289
|
if (!shortest) {
|
|
40245
40290
|
return void 0;
|
|
40246
40291
|
}
|
|
40247
|
-
return getEmitModuleResolutionKind(compilerOptions) ===
|
|
40292
|
+
return getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */ ? removeFileExtension(shortest) : removeExtensionAndIndexPostFix(shortest, ending, compilerOptions);
|
|
40248
40293
|
}
|
|
40249
40294
|
function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
40250
40295
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -40480,9 +40525,9 @@ ${lanes.join("\n")}
|
|
|
40480
40525
|
host.getSourceFiles().forEach((sf) => {
|
|
40481
40526
|
if (!sf.resolvedModules)
|
|
40482
40527
|
return;
|
|
40483
|
-
sf.resolvedModules.forEach((
|
|
40484
|
-
if (
|
|
40485
|
-
map2.set(
|
|
40528
|
+
sf.resolvedModules.forEach(({ resolvedModule }) => {
|
|
40529
|
+
if (resolvedModule == null ? void 0 : resolvedModule.packageId)
|
|
40530
|
+
map2.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!map2.get(resolvedModule.packageId.name));
|
|
40486
40531
|
});
|
|
40487
40532
|
});
|
|
40488
40533
|
return map2;
|
|
@@ -41286,6 +41331,12 @@ ${lanes.join("\n")}
|
|
|
41286
41331
|
return diagnostic;
|
|
41287
41332
|
}
|
|
41288
41333
|
function isDeprecatedSymbol(symbol) {
|
|
41334
|
+
if (length(symbol.declarations) > 1) {
|
|
41335
|
+
const parentSymbol = getParentOfSymbol(symbol);
|
|
41336
|
+
if (parentSymbol && parentSymbol.flags & 64 /* Interface */) {
|
|
41337
|
+
return some(symbol.declarations, (d) => !!(getCombinedNodeFlags(d) & 268435456 /* Deprecated */));
|
|
41338
|
+
}
|
|
41339
|
+
}
|
|
41289
41340
|
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
|
|
41290
41341
|
}
|
|
41291
41342
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
@@ -50979,7 +51030,7 @@ ${lanes.join("\n")}
|
|
|
50979
51030
|
const resolved = resolveAlias(aliasSymbol2);
|
|
50980
51031
|
if (resolved && resolved.flags & 524288 /* TypeAlias */) {
|
|
50981
51032
|
newAliasSymbol = resolved;
|
|
50982
|
-
aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node);
|
|
51033
|
+
aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node) || (typeParameters ? [] : void 0);
|
|
50983
51034
|
}
|
|
50984
51035
|
}
|
|
50985
51036
|
}
|
|
@@ -59795,13 +59846,13 @@ ${lanes.join("\n")}
|
|
|
59795
59846
|
}
|
|
59796
59847
|
const target = getReferenceCandidate(typeOfExpr.expression);
|
|
59797
59848
|
if (!isMatchingReference(reference, target)) {
|
|
59798
|
-
|
|
59849
|
+
if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
|
|
59850
|
+
type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
59851
|
+
}
|
|
59852
|
+
const propertyAccess = getDiscriminantPropertyAccess(target, type);
|
|
59799
59853
|
if (propertyAccess) {
|
|
59800
59854
|
return narrowTypeByDiscriminant(type, propertyAccess, (t) => narrowTypeByLiteralExpression(t, literal, assumeTrue));
|
|
59801
59855
|
}
|
|
59802
|
-
if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
|
|
59803
|
-
return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
|
|
59804
|
-
}
|
|
59805
59856
|
return type;
|
|
59806
59857
|
}
|
|
59807
59858
|
return narrowTypeByLiteralExpression(type, literal, assumeTrue);
|
|
@@ -70284,7 +70335,6 @@ ${lanes.join("\n")}
|
|
|
70284
70335
|
let firstDefaultClause;
|
|
70285
70336
|
let hasDuplicateDefaultClause = false;
|
|
70286
70337
|
const expressionType = checkExpression(node.expression);
|
|
70287
|
-
const expressionIsLiteral = isLiteralType(expressionType);
|
|
70288
70338
|
forEach(node.caseBlock.clauses, (clause) => {
|
|
70289
70339
|
if (clause.kind === 293 /* DefaultClause */ && !hasDuplicateDefaultClause) {
|
|
70290
70340
|
if (firstDefaultClause === void 0) {
|
|
@@ -70303,15 +70353,9 @@ ${lanes.join("\n")}
|
|
|
70303
70353
|
}
|
|
70304
70354
|
function createLazyCaseClauseDiagnostics(clause2) {
|
|
70305
70355
|
return () => {
|
|
70306
|
-
|
|
70307
|
-
|
|
70308
|
-
|
|
70309
|
-
if (!caseIsLiteral || !expressionIsLiteral) {
|
|
70310
|
-
caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
|
|
70311
|
-
comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
|
|
70312
|
-
}
|
|
70313
|
-
if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
|
|
70314
|
-
checkTypeComparableTo(caseType, comparedExpressionType, clause2.expression, void 0);
|
|
70356
|
+
const caseType = checkExpression(clause2.expression);
|
|
70357
|
+
if (!isTypeEqualityComparableTo(expressionType, caseType)) {
|
|
70358
|
+
checkTypeComparableTo(caseType, expressionType, clause2.expression, void 0);
|
|
70315
70359
|
}
|
|
70316
70360
|
};
|
|
70317
70361
|
}
|
|
@@ -73412,11 +73456,11 @@ ${lanes.join("\n")}
|
|
|
73412
73456
|
let fileToDirective;
|
|
73413
73457
|
if (resolvedTypeReferenceDirectives) {
|
|
73414
73458
|
fileToDirective = /* @__PURE__ */ new Map();
|
|
73415
|
-
resolvedTypeReferenceDirectives.forEach((
|
|
73416
|
-
if (!
|
|
73459
|
+
resolvedTypeReferenceDirectives.forEach(({ resolvedTypeReferenceDirective }, key, mode) => {
|
|
73460
|
+
if (!(resolvedTypeReferenceDirective == null ? void 0 : resolvedTypeReferenceDirective.resolvedFileName)) {
|
|
73417
73461
|
return;
|
|
73418
73462
|
}
|
|
73419
|
-
const file = host.getSourceFile(
|
|
73463
|
+
const file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
|
|
73420
73464
|
if (file) {
|
|
73421
73465
|
addReferencedFilesToTypeDirective(file, key, mode);
|
|
73422
73466
|
}
|
|
@@ -100199,25 +100243,6 @@ ${lanes.join("\n")}
|
|
|
100199
100243
|
}
|
|
100200
100244
|
return result;
|
|
100201
100245
|
}
|
|
100202
|
-
function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
|
|
100203
|
-
if (names.length === 0) {
|
|
100204
|
-
return [];
|
|
100205
|
-
}
|
|
100206
|
-
const resolutions = [];
|
|
100207
|
-
const cache = createModeAwareCache();
|
|
100208
|
-
for (const name of names) {
|
|
100209
|
-
let result;
|
|
100210
|
-
const mode = getModeForFileReference(name, containingFileMode);
|
|
100211
|
-
const strName = getResolutionName(name);
|
|
100212
|
-
if (cache.has(strName, mode)) {
|
|
100213
|
-
result = cache.get(strName, mode);
|
|
100214
|
-
} else {
|
|
100215
|
-
cache.set(strName, mode, result = loader(strName, containingFile, redirectedReference, mode));
|
|
100216
|
-
}
|
|
100217
|
-
resolutions.push(result);
|
|
100218
|
-
}
|
|
100219
|
-
return resolutions;
|
|
100220
|
-
}
|
|
100221
100246
|
function getModeForFileReference(ref, containingFileMode) {
|
|
100222
100247
|
return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
100223
100248
|
}
|
|
@@ -100283,22 +100308,53 @@ ${lanes.join("\n")}
|
|
|
100283
100308
|
}
|
|
100284
100309
|
return elem.value.text === "import" ? 99 /* ESNext */ : 1 /* CommonJS */;
|
|
100285
100310
|
}
|
|
100286
|
-
function
|
|
100287
|
-
|
|
100288
|
-
|
|
100289
|
-
|
|
100311
|
+
function getModuleResolutionName(literal) {
|
|
100312
|
+
return literal.text;
|
|
100313
|
+
}
|
|
100314
|
+
function createModuleResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
|
100315
|
+
return {
|
|
100316
|
+
nameAndMode: moduleResolutionNameAndModeGetter,
|
|
100317
|
+
resolve: (moduleName, resoluionMode) => resolveModuleName(
|
|
100318
|
+
moduleName,
|
|
100319
|
+
containingFile,
|
|
100320
|
+
options,
|
|
100321
|
+
host,
|
|
100322
|
+
cache,
|
|
100323
|
+
redirectedReference,
|
|
100324
|
+
resoluionMode
|
|
100325
|
+
)
|
|
100326
|
+
};
|
|
100327
|
+
}
|
|
100328
|
+
function getTypeReferenceResolutionName(entry) {
|
|
100329
|
+
return !isString(entry) ? toFileNameLowerCase(entry.fileName) : entry;
|
|
100330
|
+
}
|
|
100331
|
+
function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
|
100332
|
+
return {
|
|
100333
|
+
nameAndMode: typeReferenceResolutionNameAndModeGetter,
|
|
100334
|
+
resolve: (typeRef, resoluionMode) => resolveTypeReferenceDirective(
|
|
100335
|
+
typeRef,
|
|
100336
|
+
containingFile,
|
|
100337
|
+
options,
|
|
100338
|
+
host,
|
|
100339
|
+
redirectedReference,
|
|
100340
|
+
cache,
|
|
100341
|
+
resoluionMode
|
|
100342
|
+
)
|
|
100343
|
+
};
|
|
100344
|
+
}
|
|
100345
|
+
function loadWithModeAwareCache(entries, containingFile, redirectedReference, options, containingSourceFile, host, resolutionCache, createLoader) {
|
|
100346
|
+
if (entries.length === 0)
|
|
100347
|
+
return emptyArray;
|
|
100290
100348
|
const resolutions = [];
|
|
100291
|
-
const cache =
|
|
100292
|
-
|
|
100293
|
-
for (const entry of
|
|
100294
|
-
|
|
100295
|
-
const mode =
|
|
100296
|
-
|
|
100297
|
-
|
|
100298
|
-
if (
|
|
100299
|
-
result =
|
|
100300
|
-
} else {
|
|
100301
|
-
cache.set(name, mode, result = loader(name, mode, containingFileName, redirectedReference));
|
|
100349
|
+
const cache = /* @__PURE__ */ new Map();
|
|
100350
|
+
const loader = createLoader(containingFile, redirectedReference, options, host, resolutionCache);
|
|
100351
|
+
for (const entry of entries) {
|
|
100352
|
+
const name = loader.nameAndMode.getName(entry);
|
|
100353
|
+
const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
|
|
100354
|
+
const key = createModeAwareCacheKey(name, mode);
|
|
100355
|
+
let result = cache.get(key);
|
|
100356
|
+
if (!result) {
|
|
100357
|
+
cache.set(key, result = loader.resolve(name, mode));
|
|
100302
100358
|
}
|
|
100303
100359
|
resolutions.push(result);
|
|
100304
100360
|
}
|
|
@@ -100343,14 +100399,14 @@ ${lanes.join("\n")}
|
|
|
100343
100399
|
return location.pos !== void 0;
|
|
100344
100400
|
}
|
|
100345
100401
|
function getReferencedFileLocation(getSourceFileByPath, ref) {
|
|
100346
|
-
var _a2, _b, _c, _d;
|
|
100402
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
100347
100403
|
const file = Debug.checkDefined(getSourceFileByPath(ref.file));
|
|
100348
100404
|
const { kind, index } = ref;
|
|
100349
100405
|
let pos, end, packageId, resolutionMode;
|
|
100350
100406
|
switch (kind) {
|
|
100351
100407
|
case 3 /* Import */:
|
|
100352
100408
|
const importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
100353
|
-
packageId = (_b = (_a2 = file.resolvedModules) == null ? void 0 : _a2.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) == null ? void 0 : _b.packageId;
|
|
100409
|
+
packageId = (_c = (_b = (_a2 = file.resolvedModules) == null ? void 0 : _a2.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) == null ? void 0 : _b.resolvedModule) == null ? void 0 : _c.packageId;
|
|
100354
100410
|
if (importLiteral.pos === -1)
|
|
100355
100411
|
return { file, packageId, text: importLiteral.text };
|
|
100356
100412
|
pos = skipTrivia(file.text, importLiteral.pos);
|
|
@@ -100361,7 +100417,7 @@ ${lanes.join("\n")}
|
|
|
100361
100417
|
break;
|
|
100362
100418
|
case 5 /* TypeReferenceDirective */:
|
|
100363
100419
|
({ pos, end, resolutionMode } = file.typeReferenceDirectives[index]);
|
|
100364
|
-
packageId = (
|
|
100420
|
+
packageId = (_f = (_e = (_d = file.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _d.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) == null ? void 0 : _e.resolvedTypeReferenceDirective) == null ? void 0 : _f.packageId;
|
|
100365
100421
|
break;
|
|
100366
100422
|
case 7 /* LibReferenceDirective */:
|
|
100367
100423
|
({ pos, end } = file.libReferenceDirectives[index]);
|
|
@@ -100457,7 +100513,7 @@ ${lanes.join("\n")}
|
|
|
100457
100513
|
};
|
|
100458
100514
|
}
|
|
100459
100515
|
function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
100460
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
100516
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
100461
100517
|
const createProgramOptions = isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
|
|
100462
100518
|
const { rootNames, options, configFileParsingDiagnostics, projectReferences } = createProgramOptions;
|
|
100463
100519
|
let { oldProgram } = createProgramOptions;
|
|
@@ -100474,6 +100530,8 @@ ${lanes.join("\n")}
|
|
|
100474
100530
|
const cachedDeclarationDiagnosticsForFile = {};
|
|
100475
100531
|
let resolvedTypeReferenceDirectives = createModeAwareCache();
|
|
100476
100532
|
let fileProcessingDiagnostics;
|
|
100533
|
+
let automaticTypeDirectiveNames;
|
|
100534
|
+
let automaticTypeDirectiveResolutions;
|
|
100477
100535
|
const maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
|
|
100478
100536
|
let currentNodeModulesDepth = 0;
|
|
100479
100537
|
const modulesWithElidedImports = /* @__PURE__ */ new Map();
|
|
@@ -100492,50 +100550,59 @@ ${lanes.join("\n")}
|
|
|
100492
100550
|
const hasEmitBlockingDiagnostics = /* @__PURE__ */ new Map();
|
|
100493
100551
|
let _compilerOptionsObjectLiteralSyntax;
|
|
100494
100552
|
let moduleResolutionCache;
|
|
100495
|
-
let typeReferenceDirectiveResolutionCache;
|
|
100496
100553
|
let actualResolveModuleNamesWorker;
|
|
100497
100554
|
const hasInvalidatedResolutions = host.hasInvalidatedResolutions || returnFalse;
|
|
100498
|
-
if (host.
|
|
100499
|
-
actualResolveModuleNamesWorker = (
|
|
100500
|
-
var _a3;
|
|
100501
|
-
return host.resolveModuleNames(
|
|
100502
|
-
moduleNames.map((literal) => literal.text),
|
|
100503
|
-
containingFileName,
|
|
100504
|
-
(_a3 = resolutionInfo == null ? void 0 : resolutionInfo.reusedNames) == null ? void 0 : _a3.map((literal) => literal.text),
|
|
100505
|
-
redirectedReference,
|
|
100506
|
-
options,
|
|
100507
|
-
containingFile,
|
|
100508
|
-
resolutionInfo
|
|
100509
|
-
).map((resolved) => {
|
|
100510
|
-
if (!resolved || resolved.extension !== void 0) {
|
|
100511
|
-
return resolved;
|
|
100512
|
-
}
|
|
100513
|
-
const withExtension = clone(resolved);
|
|
100514
|
-
withExtension.extension = extensionFromPath(resolved.resolvedFileName);
|
|
100515
|
-
return withExtension;
|
|
100516
|
-
});
|
|
100517
|
-
};
|
|
100555
|
+
if (host.resolveModuleNameLiterals) {
|
|
100556
|
+
actualResolveModuleNamesWorker = host.resolveModuleNameLiterals.bind(host);
|
|
100518
100557
|
moduleResolutionCache = (_b = host.getModuleResolutionCache) == null ? void 0 : _b.call(host);
|
|
100558
|
+
} else if (host.resolveModuleNames) {
|
|
100559
|
+
actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile, reusedNames) => host.resolveModuleNames(
|
|
100560
|
+
moduleNames.map(getModuleResolutionName),
|
|
100561
|
+
containingFile,
|
|
100562
|
+
reusedNames == null ? void 0 : reusedNames.map(getModuleResolutionName),
|
|
100563
|
+
redirectedReference,
|
|
100564
|
+
options2,
|
|
100565
|
+
containingSourceFile
|
|
100566
|
+
).map(
|
|
100567
|
+
(resolved) => resolved ? resolved.extension !== void 0 ? { resolvedModule: resolved } : { resolvedModule: { ...resolved, extension: extensionFromPath(resolved.resolvedFileName) } } : emptyResolution
|
|
100568
|
+
);
|
|
100569
|
+
moduleResolutionCache = (_c = host.getModuleResolutionCache) == null ? void 0 : _c.call(host);
|
|
100519
100570
|
} else {
|
|
100520
100571
|
moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
100521
|
-
|
|
100522
|
-
|
|
100572
|
+
actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
|
|
100573
|
+
moduleNames,
|
|
100574
|
+
containingFile,
|
|
100575
|
+
redirectedReference,
|
|
100576
|
+
options2,
|
|
100577
|
+
containingSourceFile,
|
|
100578
|
+
host,
|
|
100579
|
+
moduleResolutionCache,
|
|
100580
|
+
createModuleResolutionLoader
|
|
100581
|
+
);
|
|
100523
100582
|
}
|
|
100524
100583
|
let actualResolveTypeReferenceDirectiveNamesWorker;
|
|
100525
|
-
if (host.
|
|
100526
|
-
actualResolveTypeReferenceDirectiveNamesWorker =
|
|
100584
|
+
if (host.resolveTypeReferenceDirectiveReferences) {
|
|
100585
|
+
actualResolveTypeReferenceDirectiveNamesWorker = host.resolveTypeReferenceDirectiveReferences.bind(host);
|
|
100586
|
+
} else if (host.resolveTypeReferenceDirectives) {
|
|
100587
|
+
actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => host.resolveTypeReferenceDirectives(
|
|
100588
|
+
typeDirectiveNames.map(getTypeReferenceResolutionName),
|
|
100589
|
+
containingFile,
|
|
100590
|
+
redirectedReference,
|
|
100591
|
+
options2,
|
|
100592
|
+
containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat
|
|
100593
|
+
).map((resolvedTypeReferenceDirective) => ({ resolvedTypeReferenceDirective }));
|
|
100527
100594
|
} else {
|
|
100528
|
-
typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
100529
|
-
|
|
100530
|
-
|
|
100595
|
+
const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
100596
|
+
actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
|
|
100597
|
+
typeDirectiveNames,
|
|
100531
100598
|
containingFile,
|
|
100532
|
-
options,
|
|
100533
|
-
host,
|
|
100534
100599
|
redirectedReference,
|
|
100600
|
+
options2,
|
|
100601
|
+
containingSourceFile,
|
|
100602
|
+
host,
|
|
100535
100603
|
typeReferenceDirectiveResolutionCache,
|
|
100536
|
-
|
|
100537
|
-
)
|
|
100538
|
-
actualResolveTypeReferenceDirectiveNamesWorker = (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) => loadWithTypeDirectiveCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader);
|
|
100604
|
+
createTypeReferenceResolutionLoader
|
|
100605
|
+
);
|
|
100539
100606
|
}
|
|
100540
100607
|
const packageIdToSourceFile = /* @__PURE__ */ new Map();
|
|
100541
100608
|
let sourceFileToPackageName = /* @__PURE__ */ new Map();
|
|
@@ -100548,7 +100615,7 @@ ${lanes.join("\n")}
|
|
|
100548
100615
|
let projectReferenceRedirects;
|
|
100549
100616
|
let mapFromFileToProjectReferenceRedirects;
|
|
100550
100617
|
let mapFromToProjectReferenceRedirectSource;
|
|
100551
|
-
const useSourceOfProjectReferenceRedirect = !!((
|
|
100618
|
+
const useSourceOfProjectReferenceRedirect = !!((_d = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _d.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
|
|
100552
100619
|
const { onProgramCreateComplete, fileExists, directoryExists } = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
100553
100620
|
compilerHost: host,
|
|
100554
100621
|
getSymlinkCache,
|
|
@@ -100559,13 +100626,13 @@ ${lanes.join("\n")}
|
|
|
100559
100626
|
forEachResolvedProjectReference: forEachResolvedProjectReference2
|
|
100560
100627
|
});
|
|
100561
100628
|
const readFile = host.readFile.bind(host);
|
|
100562
|
-
(
|
|
100629
|
+
(_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
100563
100630
|
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
100564
|
-
(
|
|
100631
|
+
(_f = tracing) == null ? void 0 : _f.pop();
|
|
100565
100632
|
let structureIsReused;
|
|
100566
|
-
(
|
|
100633
|
+
(_g = tracing) == null ? void 0 : _g.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
|
|
100567
100634
|
structureIsReused = tryReuseStructureFromOldProgram();
|
|
100568
|
-
(
|
|
100635
|
+
(_h = tracing) == null ? void 0 : _h.pop();
|
|
100569
100636
|
if (structureIsReused !== 2 /* Completely */) {
|
|
100570
100637
|
processingDefaultLibFiles = [];
|
|
100571
100638
|
processingOtherFiles = [];
|
|
@@ -100599,19 +100666,30 @@ ${lanes.join("\n")}
|
|
|
100599
100666
|
});
|
|
100600
100667
|
}
|
|
100601
100668
|
}
|
|
100602
|
-
(
|
|
100669
|
+
(_i = tracing) == null ? void 0 : _i.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
|
|
100603
100670
|
forEach(rootNames, (name, index) => processRootFile(name, false, false, { kind: 0 /* RootFile */, index }));
|
|
100604
|
-
(
|
|
100605
|
-
|
|
100606
|
-
|
|
100607
|
-
|
|
100671
|
+
(_j = tracing) == null ? void 0 : _j.pop();
|
|
100672
|
+
automaticTypeDirectiveNames != null ? automaticTypeDirectiveNames : automaticTypeDirectiveNames = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray;
|
|
100673
|
+
automaticTypeDirectiveResolutions = createModeAwareCache();
|
|
100674
|
+
if (automaticTypeDirectiveNames.length) {
|
|
100675
|
+
(_k = tracing) == null ? void 0 : _k.push(tracing.Phase.Program, "processTypeReferences", { count: automaticTypeDirectiveNames.length });
|
|
100608
100676
|
const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
|
|
100609
100677
|
const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile);
|
|
100610
|
-
const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(
|
|
100611
|
-
for (let i = 0; i <
|
|
100612
|
-
|
|
100678
|
+
const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, containingFilename);
|
|
100679
|
+
for (let i = 0; i < automaticTypeDirectiveNames.length; i++) {
|
|
100680
|
+
automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], void 0, resolutions[i]);
|
|
100681
|
+
processTypeReferenceDirective(
|
|
100682
|
+
automaticTypeDirectiveNames[i],
|
|
100683
|
+
void 0,
|
|
100684
|
+
resolutions[i],
|
|
100685
|
+
{
|
|
100686
|
+
kind: 8 /* AutomaticTypeDirectiveFile */,
|
|
100687
|
+
typeReference: automaticTypeDirectiveNames[i],
|
|
100688
|
+
packageId: (_m = (_l = resolutions[i]) == null ? void 0 : _l.resolvedTypeReferenceDirective) == null ? void 0 : _m.packageId
|
|
100689
|
+
}
|
|
100690
|
+
);
|
|
100613
100691
|
}
|
|
100614
|
-
(
|
|
100692
|
+
(_n = tracing) == null ? void 0 : _n.pop();
|
|
100615
100693
|
}
|
|
100616
100694
|
if (rootNames.length && !skipDefaultLib) {
|
|
100617
100695
|
const defaultLibraryFileName = getDefaultLibraryFileName();
|
|
@@ -100658,7 +100736,6 @@ ${lanes.join("\n")}
|
|
|
100658
100736
|
}
|
|
100659
100737
|
);
|
|
100660
100738
|
}
|
|
100661
|
-
typeReferenceDirectiveResolutionCache = void 0;
|
|
100662
100739
|
oldProgram = void 0;
|
|
100663
100740
|
const program = {
|
|
100664
100741
|
getRootFileNames: () => rootNames,
|
|
@@ -100691,6 +100768,8 @@ ${lanes.join("\n")}
|
|
|
100691
100768
|
getRelationCacheSizes: () => getTypeChecker().getRelationCacheSizes(),
|
|
100692
100769
|
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
|
|
100693
100770
|
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
|
|
100771
|
+
getAutomaticTypeDirectiveNames: () => automaticTypeDirectiveNames,
|
|
100772
|
+
getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
|
|
100694
100773
|
isSourceFileFromExternalLibrary,
|
|
100695
100774
|
isSourceFileDefaultLibrary,
|
|
100696
100775
|
getSourceFileFromReference,
|
|
@@ -100700,7 +100779,6 @@ ${lanes.join("\n")}
|
|
|
100700
100779
|
usesUriStyleNodeCoreModules,
|
|
100701
100780
|
isEmittedFile,
|
|
100702
100781
|
getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics2,
|
|
100703
|
-
getResolvedModuleWithFailedLookupLocationsFromCache,
|
|
100704
100782
|
getProjectReferences,
|
|
100705
100783
|
getResolvedProjectReferences,
|
|
100706
100784
|
getProjectReferenceRedirect,
|
|
@@ -100713,7 +100791,7 @@ ${lanes.join("\n")}
|
|
|
100713
100791
|
readFile,
|
|
100714
100792
|
directoryExists,
|
|
100715
100793
|
getSymlinkCache,
|
|
100716
|
-
realpath: (
|
|
100794
|
+
realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
|
|
100717
100795
|
useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
|
|
100718
100796
|
getFileIncludeReasons: () => fileReasons,
|
|
100719
100797
|
structureIsReused,
|
|
@@ -100727,6 +100805,8 @@ ${lanes.join("\n")}
|
|
|
100727
100805
|
case 0 /* FilePreprocessingReferencedDiagnostic */:
|
|
100728
100806
|
const { file, pos, end } = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason);
|
|
100729
100807
|
return programDiagnostics.add(createFileDiagnostic(file, Debug.checkDefined(pos), Debug.checkDefined(end) - pos, diagnostic.diagnostic, ...diagnostic.args || emptyArray));
|
|
100808
|
+
case 2 /* ResolutionDiagnostics */:
|
|
100809
|
+
return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
|
|
100730
100810
|
default:
|
|
100731
100811
|
Debug.assertNever(diagnostic);
|
|
100732
100812
|
}
|
|
@@ -100734,32 +100814,30 @@ ${lanes.join("\n")}
|
|
|
100734
100814
|
verifyCompilerOptions();
|
|
100735
100815
|
mark("afterProgram");
|
|
100736
100816
|
measure("Program", "beforeProgram", "afterProgram");
|
|
100737
|
-
(
|
|
100817
|
+
(_p = tracing) == null ? void 0 : _p.pop();
|
|
100738
100818
|
return program;
|
|
100739
|
-
function addResolutionDiagnostics(
|
|
100740
|
-
|
|
100819
|
+
function addResolutionDiagnostics(resolution) {
|
|
100820
|
+
var _a3;
|
|
100821
|
+
if (!((_a3 = resolution.resolutionDiagnostics) == null ? void 0 : _a3.length))
|
|
100741
100822
|
return;
|
|
100742
|
-
|
|
100743
|
-
|
|
100744
|
-
|
|
100823
|
+
(fileProcessingDiagnostics != null ? fileProcessingDiagnostics : fileProcessingDiagnostics = []).push({
|
|
100824
|
+
kind: 2 /* ResolutionDiagnostics */,
|
|
100825
|
+
diagnostics: resolution.resolutionDiagnostics
|
|
100826
|
+
});
|
|
100745
100827
|
}
|
|
100746
|
-
function
|
|
100747
|
-
|
|
100748
|
-
|
|
100828
|
+
function addResolutionDiagnosticsFromResolutionOrCache(containingFile, name, resolution, mode) {
|
|
100829
|
+
if (host.resolveModuleNameLiterals || !host.resolveModuleNames)
|
|
100830
|
+
return addResolutionDiagnostics(resolution);
|
|
100831
|
+
if (!moduleResolutionCache || isExternalModuleNameRelative(name))
|
|
100749
100832
|
return;
|
|
100750
100833
|
const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
|
100751
100834
|
const containingDir = getDirectoryPath(containingFileName);
|
|
100752
100835
|
const redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
100753
|
-
|
|
100754
|
-
|
|
100755
|
-
|
|
100756
|
-
if (isExternalModuleNameRelative(name))
|
|
100757
|
-
continue;
|
|
100758
|
-
const diags = (_a3 = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) == null ? void 0 : _a3.resolutionDiagnostics;
|
|
100759
|
-
addResolutionDiagnostics(diags);
|
|
100760
|
-
}
|
|
100836
|
+
const fromCache = moduleResolutionCache.getFromNonRelativeNameCache(name, mode, containingDir, redirectedReference);
|
|
100837
|
+
if (fromCache)
|
|
100838
|
+
addResolutionDiagnostics(fromCache);
|
|
100761
100839
|
}
|
|
100762
|
-
function resolveModuleNamesWorker(moduleNames, containingFile,
|
|
100840
|
+
function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
|
|
100763
100841
|
var _a3, _b2;
|
|
100764
100842
|
if (!moduleNames.length)
|
|
100765
100843
|
return emptyArray;
|
|
@@ -100767,23 +100845,22 @@ ${lanes.join("\n")}
|
|
|
100767
100845
|
const redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
100768
100846
|
(_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
|
|
100769
100847
|
mark("beforeResolveModule");
|
|
100770
|
-
const result = actualResolveModuleNamesWorker(moduleNames,
|
|
100848
|
+
const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, redirectedReference, options, containingFile, reusedNames);
|
|
100771
100849
|
mark("afterResolveModule");
|
|
100772
100850
|
measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
100773
100851
|
(_b2 = tracing) == null ? void 0 : _b2.pop();
|
|
100774
|
-
pullDiagnosticsFromCache(moduleNames, containingFile);
|
|
100775
100852
|
return result;
|
|
100776
100853
|
}
|
|
100777
|
-
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile,
|
|
100854
|
+
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, reusedNames) {
|
|
100778
100855
|
var _a3, _b2;
|
|
100779
100856
|
if (!typeDirectiveNames.length)
|
|
100780
100857
|
return [];
|
|
100858
|
+
const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
|
|
100781
100859
|
const containingFileName = !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
|
|
100782
|
-
const redirectedReference =
|
|
100783
|
-
const containingFileMode = !isString(containingFile) ? containingFile.impliedNodeFormat : void 0;
|
|
100860
|
+
const redirectedReference = containingSourceFile && getRedirectReferenceForResolution(containingSourceFile);
|
|
100784
100861
|
(_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
|
|
100785
100862
|
mark("beforeResolveTypeReference");
|
|
100786
|
-
const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference,
|
|
100863
|
+
const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, options, containingSourceFile, reusedNames);
|
|
100787
100864
|
mark("afterResolveTypeReference");
|
|
100788
100865
|
measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
|
|
100789
100866
|
(_b2 = tracing) == null ? void 0 : _b2.pop();
|
|
@@ -100829,9 +100906,6 @@ ${lanes.join("\n")}
|
|
|
100829
100906
|
}
|
|
100830
100907
|
return libs.length + 2;
|
|
100831
100908
|
}
|
|
100832
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
|
|
100833
|
-
return moduleResolutionCache && resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
|
|
100834
|
-
}
|
|
100835
100909
|
function toPath3(fileName) {
|
|
100836
100910
|
return toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
100837
100911
|
}
|
|
@@ -100860,6 +100934,7 @@ ${lanes.join("\n")}
|
|
|
100860
100934
|
return classifiableNames;
|
|
100861
100935
|
}
|
|
100862
100936
|
function resolveModuleNamesReusingOldState(moduleNames, file) {
|
|
100937
|
+
var _a3;
|
|
100863
100938
|
if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
|
|
100864
100939
|
return resolveModuleNamesWorker(moduleNames, file, void 0);
|
|
100865
100940
|
}
|
|
@@ -100875,24 +100950,24 @@ ${lanes.join("\n")}
|
|
|
100875
100950
|
let unknownModuleNames;
|
|
100876
100951
|
let result;
|
|
100877
100952
|
let reusedNames;
|
|
100878
|
-
const predictedToResolveToAmbientModuleMarker =
|
|
100953
|
+
const predictedToResolveToAmbientModuleMarker = emptyResolution;
|
|
100879
100954
|
for (let i = 0; i < moduleNames.length; i++) {
|
|
100880
100955
|
const moduleName = moduleNames[i];
|
|
100881
100956
|
if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
|
|
100882
100957
|
const mode = getModeForUsageLocation(file, moduleName);
|
|
100883
|
-
const
|
|
100884
|
-
if (
|
|
100958
|
+
const oldResolution = (_a3 = oldSourceFile.resolvedModules) == null ? void 0 : _a3.get(moduleName.text, mode);
|
|
100959
|
+
if (oldResolution == null ? void 0 : oldResolution.resolvedModule) {
|
|
100885
100960
|
if (isTraceEnabled(options, host)) {
|
|
100886
100961
|
trace(
|
|
100887
100962
|
host,
|
|
100888
|
-
|
|
100963
|
+
oldResolution.resolvedModule.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,
|
|
100889
100964
|
moduleName.text,
|
|
100890
100965
|
getNormalizedAbsolutePath(file.originalFileName, currentDirectory),
|
|
100891
|
-
|
|
100892
|
-
|
|
100966
|
+
oldResolution.resolvedModule.resolvedFileName,
|
|
100967
|
+
oldResolution.resolvedModule.packageId && packageIdToString(oldResolution.resolvedModule.packageId)
|
|
100893
100968
|
);
|
|
100894
100969
|
}
|
|
100895
|
-
(result != null ? result : result = new Array(moduleNames.length))[i] =
|
|
100970
|
+
(result != null ? result : result = new Array(moduleNames.length))[i] = oldResolution;
|
|
100896
100971
|
(reusedNames != null ? reusedNames : reusedNames = []).push(moduleName);
|
|
100897
100972
|
continue;
|
|
100898
100973
|
}
|
|
@@ -100912,18 +100987,14 @@ ${lanes.join("\n")}
|
|
|
100912
100987
|
(unknownModuleNames != null ? unknownModuleNames : unknownModuleNames = []).push(moduleName);
|
|
100913
100988
|
}
|
|
100914
100989
|
}
|
|
100915
|
-
const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file,
|
|
100990
|
+
const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames) : emptyArray;
|
|
100916
100991
|
if (!result) {
|
|
100917
100992
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
100918
100993
|
return resolutions;
|
|
100919
100994
|
}
|
|
100920
100995
|
let j = 0;
|
|
100921
100996
|
for (let i = 0; i < result.length; i++) {
|
|
100922
|
-
if (result[i]) {
|
|
100923
|
-
if (result[i] === predictedToResolveToAmbientModuleMarker) {
|
|
100924
|
-
result[i] = void 0;
|
|
100925
|
-
}
|
|
100926
|
-
} else {
|
|
100997
|
+
if (!result[i]) {
|
|
100927
100998
|
result[i] = resolutions[j];
|
|
100928
100999
|
j++;
|
|
100929
101000
|
}
|
|
@@ -100947,6 +101018,7 @@ ${lanes.join("\n")}
|
|
|
100947
101018
|
}
|
|
100948
101019
|
}
|
|
100949
101020
|
function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
|
|
101021
|
+
var _a3;
|
|
100950
101022
|
if (structureIsReused === 0 /* Not */) {
|
|
100951
101023
|
return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, void 0);
|
|
100952
101024
|
}
|
|
@@ -100955,7 +101027,7 @@ ${lanes.join("\n")}
|
|
|
100955
101027
|
if (oldSourceFile !== containingFile && containingFile.resolvedTypeReferenceDirectiveNames) {
|
|
100956
101028
|
const result2 = [];
|
|
100957
101029
|
for (const typeDirectiveName of typeDirectiveNames) {
|
|
100958
|
-
const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(
|
|
101030
|
+
const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getTypeReferenceResolutionName(typeDirectiveName), getModeForFileReference(typeDirectiveName, containingFile.impliedNodeFormat));
|
|
100959
101031
|
result2.push(resolvedTypeReferenceDirective);
|
|
100960
101032
|
}
|
|
100961
101033
|
return result2;
|
|
@@ -100969,21 +101041,21 @@ ${lanes.join("\n")}
|
|
|
100969
101041
|
for (let i = 0; i < typeDirectiveNames.length; i++) {
|
|
100970
101042
|
const entry = typeDirectiveNames[i];
|
|
100971
101043
|
if (canReuseResolutions) {
|
|
100972
|
-
const typeDirectiveName =
|
|
101044
|
+
const typeDirectiveName = getTypeReferenceResolutionName(entry);
|
|
100973
101045
|
const mode = getModeForFileReference(entry, containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat);
|
|
100974
|
-
const
|
|
100975
|
-
if (
|
|
101046
|
+
const oldResolution = (_a3 = !isString(containingFile) ? oldSourceFile == null ? void 0 : oldSourceFile.resolvedTypeReferenceDirectiveNames : oldProgram == null ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions()) == null ? void 0 : _a3.get(typeDirectiveName, mode);
|
|
101047
|
+
if (oldResolution == null ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
|
|
100976
101048
|
if (isTraceEnabled(options, host)) {
|
|
100977
101049
|
trace(
|
|
100978
101050
|
host,
|
|
100979
|
-
|
|
101051
|
+
oldResolution.resolvedTypeReferenceDirective.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
|
|
100980
101052
|
typeDirectiveName,
|
|
100981
101053
|
!isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile,
|
|
100982
|
-
|
|
100983
|
-
|
|
101054
|
+
oldResolution.resolvedTypeReferenceDirective.resolvedFileName,
|
|
101055
|
+
oldResolution.resolvedTypeReferenceDirective.packageId && packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId)
|
|
100984
101056
|
);
|
|
100985
101057
|
}
|
|
100986
|
-
(result != null ? result : result = new Array(typeDirectiveNames.length))[i] =
|
|
101058
|
+
(result != null ? result : result = new Array(typeDirectiveNames.length))[i] = oldResolution;
|
|
100987
101059
|
(reusedNames != null ? reusedNames : reusedNames = []).push(entry);
|
|
100988
101060
|
continue;
|
|
100989
101061
|
}
|
|
@@ -100995,7 +101067,7 @@ ${lanes.join("\n")}
|
|
|
100995
101067
|
const resolutions = resolveTypeReferenceDirectiveNamesWorker(
|
|
100996
101068
|
unknownTypeReferenceDirectiveNames,
|
|
100997
101069
|
containingFile,
|
|
100998
|
-
|
|
101070
|
+
reusedNames
|
|
100999
101071
|
);
|
|
101000
101072
|
if (!result) {
|
|
101001
101073
|
Debug.assert(resolutions.length === typeDirectiveNames.length);
|
|
@@ -101031,7 +101103,7 @@ ${lanes.join("\n")}
|
|
|
101031
101103
|
);
|
|
101032
101104
|
}
|
|
101033
101105
|
function tryReuseStructureFromOldProgram() {
|
|
101034
|
-
var _a3
|
|
101106
|
+
var _a3;
|
|
101035
101107
|
if (!oldProgram) {
|
|
101036
101108
|
return 0 /* Not */;
|
|
101037
101109
|
}
|
|
@@ -101141,19 +101213,19 @@ ${lanes.join("\n")}
|
|
|
101141
101213
|
for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
|
|
101142
101214
|
const moduleNames = getModuleNames(newSourceFile);
|
|
101143
101215
|
const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
101144
|
-
const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
|
|
101216
|
+
const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo, moduleResolutionNameAndModeGetter);
|
|
101145
101217
|
if (resolutionsChanged) {
|
|
101146
101218
|
structureIsReused = 1 /* SafeModules */;
|
|
101147
|
-
newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
|
|
101219
|
+
newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions, moduleResolutionNameAndModeGetter);
|
|
101148
101220
|
} else {
|
|
101149
101221
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
101150
101222
|
}
|
|
101151
101223
|
const typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
|
|
101152
101224
|
const typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
|
|
101153
|
-
const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
|
|
101225
|
+
const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo, typeReferenceResolutionNameAndModeGetter);
|
|
101154
101226
|
if (typeReferenceResolutionsChanged) {
|
|
101155
101227
|
structureIsReused = 1 /* SafeModules */;
|
|
101156
|
-
newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
|
|
101228
|
+
newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions, typeReferenceResolutionNameAndModeGetter);
|
|
101157
101229
|
} else {
|
|
101158
101230
|
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
|
101159
101231
|
}
|
|
@@ -101161,9 +101233,17 @@ ${lanes.join("\n")}
|
|
|
101161
101233
|
if (structureIsReused !== 2 /* Completely */) {
|
|
101162
101234
|
return structureIsReused;
|
|
101163
101235
|
}
|
|
101164
|
-
if (changesAffectingProgramStructure(oldOptions, options)
|
|
101236
|
+
if (changesAffectingProgramStructure(oldOptions, options)) {
|
|
101165
101237
|
return 1 /* SafeModules */;
|
|
101166
101238
|
}
|
|
101239
|
+
if (host.hasChangedAutomaticTypeDirectiveNames) {
|
|
101240
|
+
if (host.hasChangedAutomaticTypeDirectiveNames())
|
|
101241
|
+
return 1 /* SafeModules */;
|
|
101242
|
+
} else {
|
|
101243
|
+
automaticTypeDirectiveNames = getAutomaticTypeDirectiveNames(options, host);
|
|
101244
|
+
if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
|
|
101245
|
+
return 1 /* SafeModules */;
|
|
101246
|
+
}
|
|
101167
101247
|
missingFilePaths = oldProgram.getMissingFilePaths();
|
|
101168
101248
|
Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
|
|
101169
101249
|
for (const newSourceFile of newSourceFiles) {
|
|
@@ -101187,6 +101267,8 @@ ${lanes.join("\n")}
|
|
|
101187
101267
|
fileReasons = oldProgram.getFileIncludeReasons();
|
|
101188
101268
|
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
|
|
101189
101269
|
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
|
|
101270
|
+
automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
|
|
101271
|
+
automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
|
|
101190
101272
|
sourceFileToPackageName = oldProgram.sourceFileToPackageName;
|
|
101191
101273
|
redirectTargetsMap = oldProgram.redirectTargetsMap;
|
|
101192
101274
|
usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
|
|
@@ -102130,7 +102212,8 @@ ${lanes.join("\n")}
|
|
|
102130
102212
|
}
|
|
102131
102213
|
function processTypeReferenceDirectives(file) {
|
|
102132
102214
|
const typeDirectives = file.typeReferenceDirectives;
|
|
102133
|
-
if (!typeDirectives) {
|
|
102215
|
+
if (!typeDirectives.length) {
|
|
102216
|
+
file.resolvedTypeReferenceDirectiveNames = void 0;
|
|
102134
102217
|
return;
|
|
102135
102218
|
}
|
|
102136
102219
|
const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
|
|
@@ -102141,23 +102224,31 @@ ${lanes.join("\n")}
|
|
|
102141
102224
|
setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
|
|
102142
102225
|
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
102143
102226
|
if (mode && getEmitModuleResolutionKind(options) !== 3 /* Node16 */ && getEmitModuleResolutionKind(options) !== 99 /* NodeNext */) {
|
|
102144
|
-
|
|
102227
|
+
(fileProcessingDiagnostics != null ? fileProcessingDiagnostics : fileProcessingDiagnostics = []).push({
|
|
102228
|
+
kind: 2 /* ResolutionDiagnostics */,
|
|
102229
|
+
diagnostics: [
|
|
102230
|
+
createDiagnosticForRange(file, ref, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)
|
|
102231
|
+
]
|
|
102232
|
+
});
|
|
102145
102233
|
}
|
|
102146
102234
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
|
|
102147
102235
|
}
|
|
102148
102236
|
}
|
|
102149
|
-
function processTypeReferenceDirective(typeReferenceDirective, mode,
|
|
102237
|
+
function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
|
|
102150
102238
|
var _a3, _b2;
|
|
102151
|
-
(_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : void 0 });
|
|
102152
|
-
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode,
|
|
102239
|
+
(_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : void 0 });
|
|
102240
|
+
processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
|
|
102153
102241
|
(_b2 = tracing) == null ? void 0 : _b2.pop();
|
|
102154
102242
|
}
|
|
102155
|
-
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode,
|
|
102156
|
-
|
|
102243
|
+
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
|
|
102244
|
+
var _a3;
|
|
102245
|
+
addResolutionDiagnostics(resolution);
|
|
102246
|
+
const previousResolution = (_a3 = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) == null ? void 0 : _a3.resolvedTypeReferenceDirective;
|
|
102157
102247
|
if (previousResolution && previousResolution.primary) {
|
|
102158
102248
|
return;
|
|
102159
102249
|
}
|
|
102160
102250
|
let saveResolution = true;
|
|
102251
|
+
const { resolvedTypeReferenceDirective } = resolution;
|
|
102161
102252
|
if (resolvedTypeReferenceDirective) {
|
|
102162
102253
|
if (resolvedTypeReferenceDirective.isExternalLibraryImport)
|
|
102163
102254
|
currentNodeModulesDepth++;
|
|
@@ -102188,7 +102279,7 @@ ${lanes.join("\n")}
|
|
|
102188
102279
|
addFilePreprocessingFileExplainingDiagnostic(void 0, reason, Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
|
|
102189
102280
|
}
|
|
102190
102281
|
if (saveResolution) {
|
|
102191
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode,
|
|
102282
|
+
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
|
|
102192
102283
|
}
|
|
102193
102284
|
}
|
|
102194
102285
|
function pathForLibFile(libFileName) {
|
|
@@ -102237,8 +102328,11 @@ ${lanes.join("\n")}
|
|
|
102237
102328
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
102238
102329
|
const optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a3 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a3.commandLine.options : void 0) || options;
|
|
102239
102330
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
102240
|
-
const resolution = resolutions[index];
|
|
102241
|
-
|
|
102331
|
+
const resolution = resolutions[index].resolvedModule;
|
|
102332
|
+
const moduleName = moduleNames[index].text;
|
|
102333
|
+
const mode = getModeForUsageLocation(file, moduleNames[index]);
|
|
102334
|
+
setResolvedModule(file, moduleName, resolutions[index], mode);
|
|
102335
|
+
addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode);
|
|
102242
102336
|
if (!resolution) {
|
|
102243
102337
|
continue;
|
|
102244
102338
|
}
|
|
@@ -102879,8 +102973,8 @@ ${lanes.join("\n")}
|
|
|
102879
102973
|
if (!symlinks) {
|
|
102880
102974
|
symlinks = createSymlinkCache(currentDirectory, getCanonicalFileName);
|
|
102881
102975
|
}
|
|
102882
|
-
if (files &&
|
|
102883
|
-
symlinks.setSymlinksFromResolutions(files,
|
|
102976
|
+
if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
|
|
102977
|
+
symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
|
|
102884
102978
|
}
|
|
102885
102979
|
return symlinks;
|
|
102886
102980
|
}
|
|
@@ -103123,7 +103217,7 @@ ${lanes.join("\n")}
|
|
|
103123
103217
|
}
|
|
103124
103218
|
Debug.fail("should never ask for module name at index higher than possible module name");
|
|
103125
103219
|
}
|
|
103126
|
-
var ForegroundColorEscapeSequences, gutterStyleSequence, gutterSeparator, resetEscapeSequence, ellipsis, halfIndent, indent, inferredTypesContainingFile, plainJSErrors, emitSkippedWithNoDiagnostics;
|
|
103220
|
+
var ForegroundColorEscapeSequences, gutterStyleSequence, gutterSeparator, resetEscapeSequence, ellipsis, halfIndent, indent, emptyResolution, moduleResolutionNameAndModeGetter, typeReferenceResolutionNameAndModeGetter, inferredTypesContainingFile, plainJSErrors, emitSkippedWithNoDiagnostics;
|
|
103127
103221
|
var init_program = __esm({
|
|
103128
103222
|
"src/compiler/program.ts"() {
|
|
103129
103223
|
"use strict";
|
|
@@ -103144,6 +103238,18 @@ ${lanes.join("\n")}
|
|
|
103144
103238
|
ellipsis = "...";
|
|
103145
103239
|
halfIndent = " ";
|
|
103146
103240
|
indent = " ";
|
|
103241
|
+
emptyResolution = {
|
|
103242
|
+
resolvedModule: void 0,
|
|
103243
|
+
resolvedTypeReferenceDirective: void 0
|
|
103244
|
+
};
|
|
103245
|
+
moduleResolutionNameAndModeGetter = {
|
|
103246
|
+
getName: getModuleResolutionName,
|
|
103247
|
+
getMode: (entry, file) => getModeForUsageLocation(file, entry)
|
|
103248
|
+
};
|
|
103249
|
+
typeReferenceResolutionNameAndModeGetter = {
|
|
103250
|
+
getName: getTypeReferenceResolutionName,
|
|
103251
|
+
getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
|
|
103252
|
+
};
|
|
103147
103253
|
inferredTypesContainingFile = "__inferred type names__.ts";
|
|
103148
103254
|
plainJSErrors = /* @__PURE__ */ new Set([
|
|
103149
103255
|
Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
|
|
@@ -103350,7 +103456,7 @@ ${lanes.join("\n")}
|
|
|
103350
103456
|
}
|
|
103351
103457
|
}
|
|
103352
103458
|
if (sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
103353
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => {
|
|
103459
|
+
sourceFile.resolvedTypeReferenceDirectiveNames.forEach(({ resolvedTypeReferenceDirective }) => {
|
|
103354
103460
|
if (!resolvedTypeReferenceDirective) {
|
|
103355
103461
|
return;
|
|
103356
103462
|
}
|
|
@@ -103472,6 +103578,26 @@ ${lanes.join("\n")}
|
|
|
103472
103578
|
(state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = /* @__PURE__ */ new Set())).add(path);
|
|
103473
103579
|
}
|
|
103474
103580
|
BuilderState2.updateSignatureOfFile = updateSignatureOfFile;
|
|
103581
|
+
function computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, onNewSignature) {
|
|
103582
|
+
programOfThisState.emit(
|
|
103583
|
+
sourceFile,
|
|
103584
|
+
(fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
|
|
103585
|
+
Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
|
|
103586
|
+
onNewSignature(computeSignatureWithDiagnostics(
|
|
103587
|
+
programOfThisState,
|
|
103588
|
+
sourceFile,
|
|
103589
|
+
text,
|
|
103590
|
+
host,
|
|
103591
|
+
data
|
|
103592
|
+
), sourceFiles);
|
|
103593
|
+
},
|
|
103594
|
+
cancellationToken,
|
|
103595
|
+
true,
|
|
103596
|
+
void 0,
|
|
103597
|
+
true
|
|
103598
|
+
);
|
|
103599
|
+
}
|
|
103600
|
+
BuilderState2.computeDtsSignature = computeDtsSignature;
|
|
103475
103601
|
function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature = state.useFileVersionAsSignature) {
|
|
103476
103602
|
var _a2;
|
|
103477
103603
|
if ((_a2 = state.hasCalledUpdateShapeSignature) == null ? void 0 : _a2.has(sourceFile.resolvedPath))
|
|
@@ -103480,26 +103606,12 @@ ${lanes.join("\n")}
|
|
|
103480
103606
|
const prevSignature = info.signature;
|
|
103481
103607
|
let latestSignature;
|
|
103482
103608
|
if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
|
|
103483
|
-
programOfThisState
|
|
103484
|
-
|
|
103485
|
-
(
|
|
103486
|
-
|
|
103487
|
-
|
|
103488
|
-
|
|
103489
|
-
sourceFile,
|
|
103490
|
-
text,
|
|
103491
|
-
host,
|
|
103492
|
-
data
|
|
103493
|
-
);
|
|
103494
|
-
if (latestSignature !== prevSignature) {
|
|
103495
|
-
updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
|
|
103496
|
-
}
|
|
103497
|
-
},
|
|
103498
|
-
cancellationToken,
|
|
103499
|
-
true,
|
|
103500
|
-
void 0,
|
|
103501
|
-
true
|
|
103502
|
-
);
|
|
103609
|
+
computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, (signature, sourceFiles) => {
|
|
103610
|
+
latestSignature = signature;
|
|
103611
|
+
if (latestSignature !== prevSignature) {
|
|
103612
|
+
updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
|
|
103613
|
+
}
|
|
103614
|
+
});
|
|
103503
103615
|
}
|
|
103504
103616
|
if (latestSignature === void 0) {
|
|
103505
103617
|
latestSignature = sourceFile.version;
|
|
@@ -103523,27 +103635,24 @@ ${lanes.join("\n")}
|
|
|
103523
103635
|
if (!state.exportedModulesMap)
|
|
103524
103636
|
return;
|
|
103525
103637
|
(state.oldExportedModulesMap || (state.oldExportedModulesMap = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
|
|
103526
|
-
|
|
103527
|
-
state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
|
|
103528
|
-
return;
|
|
103529
|
-
}
|
|
103530
|
-
let exportedModules;
|
|
103531
|
-
exportedModulesFromDeclarationEmit.forEach((symbol) => addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)));
|
|
103638
|
+
const exportedModules = getExportedModules(exportedModulesFromDeclarationEmit);
|
|
103532
103639
|
if (exportedModules) {
|
|
103533
103640
|
state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
|
|
103534
103641
|
} else {
|
|
103535
103642
|
state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
|
|
103536
103643
|
}
|
|
103537
|
-
function addExportedModule(exportedModulePaths) {
|
|
103538
|
-
if (exportedModulePaths == null ? void 0 : exportedModulePaths.length) {
|
|
103539
|
-
if (!exportedModules) {
|
|
103540
|
-
exportedModules = /* @__PURE__ */ new Set();
|
|
103541
|
-
}
|
|
103542
|
-
exportedModulePaths.forEach((path) => exportedModules.add(path));
|
|
103543
|
-
}
|
|
103544
|
-
}
|
|
103545
103644
|
}
|
|
103546
103645
|
BuilderState2.updateExportedModules = updateExportedModules;
|
|
103646
|
+
function getExportedModules(exportedModulesFromDeclarationEmit) {
|
|
103647
|
+
let exportedModules;
|
|
103648
|
+
exportedModulesFromDeclarationEmit == null ? void 0 : exportedModulesFromDeclarationEmit.forEach(
|
|
103649
|
+
(symbol) => getReferencedFilesFromImportedModuleSymbol(symbol).forEach(
|
|
103650
|
+
(path) => (exportedModules != null ? exportedModules : exportedModules = /* @__PURE__ */ new Set()).add(path)
|
|
103651
|
+
)
|
|
103652
|
+
);
|
|
103653
|
+
return exportedModules;
|
|
103654
|
+
}
|
|
103655
|
+
BuilderState2.getExportedModules = getExportedModules;
|
|
103547
103656
|
function getAllDependencies(state, programOfThisState, sourceFile) {
|
|
103548
103657
|
const compilerOptions = programOfThisState.getCompilerOptions();
|
|
103549
103658
|
if (outFile(compilerOptions)) {
|
|
@@ -103687,9 +103796,9 @@ ${lanes.join("\n")}
|
|
|
103687
103796
|
function hasSameKeys(map1, map2) {
|
|
103688
103797
|
return map1 === map2 || map1 !== void 0 && map2 !== void 0 && map1.size === map2.size && !forEachKey(map1, (key) => !map2.has(key));
|
|
103689
103798
|
}
|
|
103690
|
-
function createBuilderProgramState(newProgram, oldState
|
|
103799
|
+
function createBuilderProgramState(newProgram, oldState) {
|
|
103691
103800
|
var _a2, _b;
|
|
103692
|
-
const state = BuilderState.create(newProgram, oldState,
|
|
103801
|
+
const state = BuilderState.create(newProgram, oldState, false);
|
|
103693
103802
|
state.program = newProgram;
|
|
103694
103803
|
const compilerOptions = newProgram.getCompilerOptions();
|
|
103695
103804
|
state.compilerOptions = compilerOptions;
|
|
@@ -103981,7 +104090,7 @@ ${lanes.join("\n")}
|
|
|
103981
104090
|
sourceFile,
|
|
103982
104091
|
cancellationToken,
|
|
103983
104092
|
host,
|
|
103984
|
-
|
|
104093
|
+
true
|
|
103985
104094
|
);
|
|
103986
104095
|
if (getEmitDeclarations(state.compilerOptions)) {
|
|
103987
104096
|
addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
|
|
@@ -104364,7 +104473,7 @@ ${lanes.join("\n")}
|
|
|
104364
104473
|
oldState = void 0;
|
|
104365
104474
|
return oldProgram;
|
|
104366
104475
|
}
|
|
104367
|
-
const state = createBuilderProgramState(newProgram, oldState
|
|
104476
|
+
const state = createBuilderProgramState(newProgram, oldState);
|
|
104368
104477
|
newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, bundle);
|
|
104369
104478
|
newProgram = void 0;
|
|
104370
104479
|
oldProgram = void 0;
|
|
@@ -104861,9 +104970,9 @@ ${lanes.join("\n")}
|
|
|
104861
104970
|
let filesWithInvalidatedResolutions;
|
|
104862
104971
|
let filesWithInvalidatedNonRelativeUnresolvedImports;
|
|
104863
104972
|
const nonRelativeExternalModuleResolutions = createMultiMap();
|
|
104864
|
-
const resolutionsWithFailedLookups =
|
|
104865
|
-
const resolutionsWithOnlyAffectingLocations =
|
|
104866
|
-
const resolvedFileToResolution =
|
|
104973
|
+
const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
|
|
104974
|
+
const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
|
|
104975
|
+
const resolvedFileToResolution = /* @__PURE__ */ new Map();
|
|
104867
104976
|
const impliedFormatPackageJsons = /* @__PURE__ */ new Map();
|
|
104868
104977
|
let hasChangedAutomaticTypeDirectiveNames = false;
|
|
104869
104978
|
let affectingPathChecksForFile;
|
|
@@ -104900,9 +105009,9 @@ ${lanes.join("\n")}
|
|
|
104900
105009
|
finishRecordingFilesWithChangedResolutions,
|
|
104901
105010
|
startCachingPerDirectoryResolution,
|
|
104902
105011
|
finishCachingPerDirectoryResolution,
|
|
104903
|
-
|
|
104904
|
-
|
|
104905
|
-
|
|
105012
|
+
resolveModuleNameLiterals,
|
|
105013
|
+
resolveTypeReferenceDirectiveReferences,
|
|
105014
|
+
resolveSingleModuleNameWithoutWatching,
|
|
104906
105015
|
removeResolutionsFromProjectReferenceRedirects,
|
|
104907
105016
|
removeResolutionsOfFile,
|
|
104908
105017
|
hasChangedAutomaticTypeDirectiveNames: () => hasChangedAutomaticTypeDirectiveNames,
|
|
@@ -104936,8 +105045,8 @@ ${lanes.join("\n")}
|
|
|
104936
105045
|
resolvedModuleNames.clear();
|
|
104937
105046
|
resolvedTypeReferenceDirectives.clear();
|
|
104938
105047
|
resolvedFileToResolution.clear();
|
|
104939
|
-
resolutionsWithFailedLookups.
|
|
104940
|
-
resolutionsWithOnlyAffectingLocations.
|
|
105048
|
+
resolutionsWithFailedLookups.clear();
|
|
105049
|
+
resolutionsWithOnlyAffectingLocations.clear();
|
|
104941
105050
|
failedLookupChecks = void 0;
|
|
104942
105051
|
startsWithPathChecks = void 0;
|
|
104943
105052
|
isInDirectoryChecks = void 0;
|
|
@@ -105020,14 +105129,16 @@ ${lanes.join("\n")}
|
|
|
105020
105129
|
});
|
|
105021
105130
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
105022
105131
|
}
|
|
105023
|
-
function resolveModuleName2(moduleName, containingFile, compilerOptions,
|
|
105132
|
+
function resolveModuleName2(moduleName, containingFile, compilerOptions, redirectedReference, mode) {
|
|
105133
|
+
var _a2;
|
|
105134
|
+
const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
|
|
105024
105135
|
const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
|
|
105025
105136
|
if (!resolutionHost.getGlobalCache) {
|
|
105026
105137
|
return primaryResult;
|
|
105027
105138
|
}
|
|
105028
105139
|
const globalCache = resolutionHost.getGlobalCache();
|
|
105029
105140
|
if (globalCache !== void 0 && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) {
|
|
105030
|
-
const { resolvedModule, failedLookupLocations, affectingLocations } = loadModuleFromGlobalCache(
|
|
105141
|
+
const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache(
|
|
105031
105142
|
Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
|
|
105032
105143
|
resolutionHost.projectName,
|
|
105033
105144
|
compilerOptions,
|
|
@@ -105037,49 +105148,55 @@ ${lanes.join("\n")}
|
|
|
105037
105148
|
);
|
|
105038
105149
|
if (resolvedModule) {
|
|
105039
105150
|
primaryResult.resolvedModule = resolvedModule;
|
|
105040
|
-
primaryResult.failedLookupLocations.
|
|
105041
|
-
primaryResult.affectingLocations.
|
|
105151
|
+
primaryResult.failedLookupLocations = updateResolutionField(primaryResult.failedLookupLocations, failedLookupLocations);
|
|
105152
|
+
primaryResult.affectingLocations = updateResolutionField(primaryResult.affectingLocations, affectingLocations);
|
|
105153
|
+
primaryResult.resolutionDiagnostics = updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
|
|
105042
105154
|
return primaryResult;
|
|
105043
105155
|
}
|
|
105044
105156
|
}
|
|
105045
105157
|
return primaryResult;
|
|
105046
105158
|
}
|
|
105047
|
-
function
|
|
105048
|
-
return
|
|
105159
|
+
function createModuleResolutionLoader2(containingFile, redirectedReference, options) {
|
|
105160
|
+
return {
|
|
105161
|
+
nameAndMode: moduleResolutionNameAndModeGetter,
|
|
105162
|
+
resolve: (moduleName, resoluionMode) => resolveModuleName2(
|
|
105163
|
+
moduleName,
|
|
105164
|
+
containingFile,
|
|
105165
|
+
options,
|
|
105166
|
+
redirectedReference,
|
|
105167
|
+
resoluionMode
|
|
105168
|
+
)
|
|
105169
|
+
};
|
|
105049
105170
|
}
|
|
105050
105171
|
function resolveNamesWithLocalCache({
|
|
105051
|
-
|
|
105172
|
+
entries,
|
|
105052
105173
|
containingFile,
|
|
105174
|
+
containingSourceFile,
|
|
105053
105175
|
redirectedReference,
|
|
105176
|
+
options,
|
|
105054
105177
|
perFileCache,
|
|
105178
|
+
reusedNames,
|
|
105055
105179
|
loader,
|
|
105056
105180
|
getResolutionWithResolvedFileName,
|
|
105057
105181
|
shouldRetryResolution,
|
|
105058
|
-
|
|
105059
|
-
resolutionInfo,
|
|
105060
|
-
logChanges,
|
|
105061
|
-
containingSourceFile,
|
|
105062
|
-
containingSourceFileMode
|
|
105182
|
+
logChanges
|
|
105063
105183
|
}) {
|
|
105064
|
-
var _a2
|
|
105184
|
+
var _a2;
|
|
105065
105185
|
const path = resolutionHost.toPath(containingFile);
|
|
105066
105186
|
const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
|
|
105067
105187
|
const resolvedModules = [];
|
|
105068
|
-
const compilerOptions = resolutionHost.getCompilationSettings();
|
|
105069
105188
|
const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
|
|
105070
105189
|
const program = resolutionHost.getCurrentProgram();
|
|
105071
105190
|
const oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
|
|
105072
105191
|
const unmatchedRedirects = oldRedirect ? !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference;
|
|
105073
105192
|
const seenNamesInFile = createModeAwareCache();
|
|
105074
|
-
|
|
105075
|
-
|
|
105076
|
-
const
|
|
105077
|
-
const mode = !isString(entry) ? isStringLiteralLike(entry) ? getModeForUsageLocation(containingSourceFile, entry) : getModeForFileReference(entry, containingSourceFileMode) : containingSourceFile ? getModeForResolutionAtIndex(containingSourceFile, i) : void 0;
|
|
105078
|
-
i++;
|
|
105193
|
+
for (const entry of entries) {
|
|
105194
|
+
const name = loader.nameAndMode.getName(entry);
|
|
105195
|
+
const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
|
|
105079
105196
|
let resolution = resolutionsInFile.get(name, mode);
|
|
105080
105197
|
if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
|
|
105081
105198
|
const existingResolution = resolution;
|
|
105082
|
-
resolution = loader(name,
|
|
105199
|
+
resolution = loader.resolve(name, mode);
|
|
105083
105200
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
105084
105201
|
resolutionHost.onDiscoveredSymlink();
|
|
105085
105202
|
}
|
|
@@ -105093,12 +105210,12 @@ ${lanes.join("\n")}
|
|
|
105093
105210
|
logChanges = false;
|
|
105094
105211
|
}
|
|
105095
105212
|
} else {
|
|
105096
|
-
const host = ((
|
|
105097
|
-
if (isTraceEnabled(
|
|
105213
|
+
const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
|
|
105214
|
+
if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) {
|
|
105098
105215
|
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
105099
105216
|
trace(
|
|
105100
105217
|
host,
|
|
105101
|
-
|
|
105218
|
+
perFileCache === resolvedModuleNames ? (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 : (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved,
|
|
105102
105219
|
name,
|
|
105103
105220
|
containingFile,
|
|
105104
105221
|
resolved == null ? void 0 : resolved.resolvedFileName,
|
|
@@ -105108,19 +105225,16 @@ ${lanes.join("\n")}
|
|
|
105108
105225
|
}
|
|
105109
105226
|
Debug.assert(resolution !== void 0 && !resolution.isInvalidated);
|
|
105110
105227
|
seenNamesInFile.set(name, mode, true);
|
|
105111
|
-
resolvedModules.push(
|
|
105112
|
-
}
|
|
105113
|
-
if (resolutionInfo && (loader === resolveTypeReferenceDirective2 || containingSourceFile)) {
|
|
105114
|
-
(_c = resolutionInfo.reusedNames) == null ? void 0 : _c.forEach((entry) => seenNamesInFile.set(
|
|
105115
|
-
getResolutionName(entry),
|
|
105116
|
-
!isString(entry) && isStringLiteralLike(entry) ? getModeForUsageLocation(containingSourceFile, entry) : getModeForFileReference(entry, containingSourceFileMode),
|
|
105117
|
-
true
|
|
105118
|
-
));
|
|
105119
|
-
reusedNames = void 0;
|
|
105228
|
+
resolvedModules.push(resolution);
|
|
105120
105229
|
}
|
|
105230
|
+
reusedNames == null ? void 0 : reusedNames.forEach((entry) => seenNamesInFile.set(
|
|
105231
|
+
loader.nameAndMode.getName(entry),
|
|
105232
|
+
loader.nameAndMode.getMode(entry, containingSourceFile),
|
|
105233
|
+
true
|
|
105234
|
+
));
|
|
105121
105235
|
if (resolutionsInFile.size() !== seenNamesInFile.size()) {
|
|
105122
105236
|
resolutionsInFile.forEach((resolution, name, mode) => {
|
|
105123
|
-
if (!seenNamesInFile.has(name, mode)
|
|
105237
|
+
if (!seenNamesInFile.has(name, mode)) {
|
|
105124
105238
|
stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
105125
105239
|
resolutionsInFile.delete(name, mode);
|
|
105126
105240
|
}
|
|
@@ -105145,39 +105259,53 @@ ${lanes.join("\n")}
|
|
|
105145
105259
|
return oldResult.resolvedFileName === newResult.resolvedFileName;
|
|
105146
105260
|
}
|
|
105147
105261
|
}
|
|
105148
|
-
function
|
|
105262
|
+
function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
|
|
105263
|
+
var _a2;
|
|
105149
105264
|
return resolveNamesWithLocalCache({
|
|
105150
|
-
|
|
105265
|
+
entries: typeDirectiveReferences,
|
|
105151
105266
|
containingFile,
|
|
105267
|
+
containingSourceFile,
|
|
105152
105268
|
redirectedReference,
|
|
105269
|
+
options,
|
|
105270
|
+
reusedNames,
|
|
105153
105271
|
perFileCache: resolvedTypeReferenceDirectives,
|
|
105154
|
-
loader:
|
|
105272
|
+
loader: createTypeReferenceResolutionLoader(
|
|
105273
|
+
containingFile,
|
|
105274
|
+
redirectedReference,
|
|
105275
|
+
options,
|
|
105276
|
+
((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost,
|
|
105277
|
+
typeReferenceDirectiveResolutionCache
|
|
105278
|
+
),
|
|
105155
105279
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective2,
|
|
105156
|
-
shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0
|
|
105157
|
-
containingSourceFileMode: containingFileMode,
|
|
105158
|
-
resolutionInfo
|
|
105280
|
+
shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0
|
|
105159
105281
|
});
|
|
105160
105282
|
}
|
|
105161
|
-
function
|
|
105283
|
+
function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
|
|
105162
105284
|
return resolveNamesWithLocalCache({
|
|
105163
|
-
|
|
105285
|
+
entries: moduleLiterals,
|
|
105164
105286
|
containingFile,
|
|
105287
|
+
containingSourceFile,
|
|
105165
105288
|
redirectedReference,
|
|
105289
|
+
options,
|
|
105290
|
+
reusedNames,
|
|
105166
105291
|
perFileCache: resolvedModuleNames,
|
|
105167
|
-
loader:
|
|
105292
|
+
loader: createModuleResolutionLoader2(
|
|
105293
|
+
containingFile,
|
|
105294
|
+
redirectedReference,
|
|
105295
|
+
options
|
|
105296
|
+
),
|
|
105168
105297
|
getResolutionWithResolvedFileName: getResolvedModule2,
|
|
105169
105298
|
shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
|
|
105170
|
-
|
|
105171
|
-
resolutionInfo,
|
|
105172
|
-
logChanges: logChangesWhenResolvingModule,
|
|
105173
|
-
containingSourceFile
|
|
105299
|
+
logChanges: logChangesWhenResolvingModule
|
|
105174
105300
|
});
|
|
105175
105301
|
}
|
|
105176
|
-
function
|
|
105177
|
-
const
|
|
105178
|
-
|
|
105179
|
-
|
|
105180
|
-
|
|
105302
|
+
function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) {
|
|
105303
|
+
const path = resolutionHost.toPath(containingFile);
|
|
105304
|
+
const resolutionsInFile = resolvedModuleNames.get(path);
|
|
105305
|
+
const resolution = resolutionsInFile == null ? void 0 : resolutionsInFile.get(moduleName, void 0);
|
|
105306
|
+
if (resolution && !resolution.isInvalidated)
|
|
105307
|
+
return resolution;
|
|
105308
|
+
return resolveModuleName2(moduleName, containingFile, resolutionHost.getCompilationSettings());
|
|
105181
105309
|
}
|
|
105182
105310
|
function isNodeModulesAtTypesDirectory(dirPath) {
|
|
105183
105311
|
return endsWith(dirPath, "/node_modules/@types");
|
|
@@ -105235,12 +105363,13 @@ ${lanes.join("\n")}
|
|
|
105235
105363
|
return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
105236
105364
|
}
|
|
105237
105365
|
function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
|
|
105366
|
+
var _a2, _b;
|
|
105238
105367
|
if (resolution.refCount) {
|
|
105239
105368
|
resolution.refCount++;
|
|
105240
105369
|
Debug.assertIsDefined(resolution.files);
|
|
105241
105370
|
} else {
|
|
105242
105371
|
resolution.refCount = 1;
|
|
105243
|
-
Debug.assert(
|
|
105372
|
+
Debug.assert(!((_a2 = resolution.files) == null ? void 0 : _a2.size));
|
|
105244
105373
|
if (isExternalModuleNameRelative(name)) {
|
|
105245
105374
|
watchFailedLookupLocationOfResolution(resolution);
|
|
105246
105375
|
} else {
|
|
@@ -105248,48 +105377,54 @@ ${lanes.join("\n")}
|
|
|
105248
105377
|
}
|
|
105249
105378
|
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
105250
105379
|
if (resolved && resolved.resolvedFileName) {
|
|
105251
|
-
|
|
105380
|
+
const key = resolutionHost.toPath(resolved.resolvedFileName);
|
|
105381
|
+
let resolutions = resolvedFileToResolution.get(key);
|
|
105382
|
+
if (!resolutions)
|
|
105383
|
+
resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
|
|
105384
|
+
resolutions.add(resolution);
|
|
105252
105385
|
}
|
|
105253
105386
|
}
|
|
105254
|
-
(resolution.files
|
|
105387
|
+
((_b = resolution.files) != null ? _b : resolution.files = /* @__PURE__ */ new Set()).add(filePath);
|
|
105255
105388
|
}
|
|
105256
105389
|
function watchFailedLookupLocationOfResolution(resolution) {
|
|
105257
105390
|
Debug.assert(!!resolution.refCount);
|
|
105258
105391
|
const { failedLookupLocations, affectingLocations } = resolution;
|
|
105259
|
-
if (!failedLookupLocations.length && !affectingLocations.length)
|
|
105392
|
+
if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length))
|
|
105260
105393
|
return;
|
|
105261
|
-
if (failedLookupLocations.length)
|
|
105262
|
-
resolutionsWithFailedLookups.
|
|
105394
|
+
if (failedLookupLocations == null ? void 0 : failedLookupLocations.length)
|
|
105395
|
+
resolutionsWithFailedLookups.add(resolution);
|
|
105263
105396
|
let setAtRoot = false;
|
|
105264
|
-
|
|
105265
|
-
const
|
|
105266
|
-
|
|
105267
|
-
|
|
105268
|
-
|
|
105269
|
-
|
|
105270
|
-
|
|
105271
|
-
|
|
105272
|
-
|
|
105273
|
-
|
|
105274
|
-
|
|
105275
|
-
|
|
105276
|
-
|
|
105277
|
-
|
|
105397
|
+
if (failedLookupLocations) {
|
|
105398
|
+
for (const failedLookupLocation of failedLookupLocations) {
|
|
105399
|
+
const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
105400
|
+
const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
|
|
105401
|
+
if (toWatch) {
|
|
105402
|
+
const { dir, dirPath, nonRecursive } = toWatch;
|
|
105403
|
+
if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
|
|
105404
|
+
const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
|
|
105405
|
+
customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
|
|
105406
|
+
}
|
|
105407
|
+
if (dirPath === rootPath) {
|
|
105408
|
+
Debug.assert(!nonRecursive);
|
|
105409
|
+
setAtRoot = true;
|
|
105410
|
+
} else {
|
|
105411
|
+
setDirectoryWatcher(dir, dirPath, nonRecursive);
|
|
105412
|
+
}
|
|
105278
105413
|
}
|
|
105279
105414
|
}
|
|
105415
|
+
if (setAtRoot) {
|
|
105416
|
+
setDirectoryWatcher(rootDir, rootPath, true);
|
|
105417
|
+
}
|
|
105280
105418
|
}
|
|
105281
|
-
|
|
105282
|
-
setDirectoryWatcher(rootDir, rootPath, true);
|
|
105283
|
-
}
|
|
105284
|
-
watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
|
|
105419
|
+
watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length));
|
|
105285
105420
|
}
|
|
105286
105421
|
function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
|
|
105287
105422
|
Debug.assert(!!resolution.refCount);
|
|
105288
105423
|
const { affectingLocations } = resolution;
|
|
105289
|
-
if (!affectingLocations.length)
|
|
105424
|
+
if (!(affectingLocations == null ? void 0 : affectingLocations.length))
|
|
105290
105425
|
return;
|
|
105291
105426
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
105292
|
-
resolutionsWithOnlyAffectingLocations.
|
|
105427
|
+
resolutionsWithOnlyAffectingLocations.add(resolution);
|
|
105293
105428
|
for (const affectingLocation of affectingLocations) {
|
|
105294
105429
|
createFileWatcherOfAffectingLocation(affectingLocation, true);
|
|
105295
105430
|
}
|
|
@@ -105368,17 +105503,20 @@ ${lanes.join("\n")}
|
|
|
105368
105503
|
}
|
|
105369
105504
|
}
|
|
105370
105505
|
function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
|
|
105371
|
-
|
|
105506
|
+
Debug.checkDefined(resolution.files).delete(filePath);
|
|
105372
105507
|
resolution.refCount--;
|
|
105373
105508
|
if (resolution.refCount) {
|
|
105374
105509
|
return;
|
|
105375
105510
|
}
|
|
105376
105511
|
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
105377
105512
|
if (resolved && resolved.resolvedFileName) {
|
|
105378
|
-
|
|
105513
|
+
const key = resolutionHost.toPath(resolved.resolvedFileName);
|
|
105514
|
+
const resolutions = resolvedFileToResolution.get(key);
|
|
105515
|
+
if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size)
|
|
105516
|
+
resolvedFileToResolution.delete(key);
|
|
105379
105517
|
}
|
|
105380
105518
|
const { failedLookupLocations, affectingLocations } = resolution;
|
|
105381
|
-
if (
|
|
105519
|
+
if (resolutionsWithFailedLookups.delete(resolution)) {
|
|
105382
105520
|
let removeAtRoot = false;
|
|
105383
105521
|
for (const failedLookupLocation of failedLookupLocations) {
|
|
105384
105522
|
const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
@@ -105404,12 +105542,14 @@ ${lanes.join("\n")}
|
|
|
105404
105542
|
if (removeAtRoot) {
|
|
105405
105543
|
removeDirectoryWatcher(rootPath);
|
|
105406
105544
|
}
|
|
105407
|
-
} else if (affectingLocations.length) {
|
|
105408
|
-
|
|
105545
|
+
} else if (affectingLocations == null ? void 0 : affectingLocations.length) {
|
|
105546
|
+
resolutionsWithOnlyAffectingLocations.delete(resolution);
|
|
105409
105547
|
}
|
|
105410
|
-
|
|
105411
|
-
const
|
|
105412
|
-
|
|
105548
|
+
if (affectingLocations) {
|
|
105549
|
+
for (const affectingLocation of affectingLocations) {
|
|
105550
|
+
const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
105551
|
+
watcher.resolutions--;
|
|
105552
|
+
}
|
|
105413
105553
|
}
|
|
105414
105554
|
}
|
|
105415
105555
|
function removeDirectoryWatcher(dirPath) {
|
|
@@ -105451,15 +105591,15 @@ ${lanes.join("\n")}
|
|
|
105451
105591
|
if (!resolutions)
|
|
105452
105592
|
return false;
|
|
105453
105593
|
let invalidated = false;
|
|
105454
|
-
|
|
105594
|
+
resolutions.forEach((resolution) => {
|
|
105455
105595
|
if (resolution.isInvalidated || !canInvalidate(resolution))
|
|
105456
|
-
|
|
105596
|
+
return;
|
|
105457
105597
|
resolution.isInvalidated = invalidated = true;
|
|
105458
105598
|
for (const containingFilePath of Debug.checkDefined(resolution.files)) {
|
|
105459
105599
|
(filesWithInvalidatedResolutions != null ? filesWithInvalidatedResolutions : filesWithInvalidatedResolutions = /* @__PURE__ */ new Set()).add(containingFilePath);
|
|
105460
105600
|
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
|
|
105461
105601
|
}
|
|
105462
|
-
}
|
|
105602
|
+
});
|
|
105463
105603
|
return invalidated;
|
|
105464
105604
|
}
|
|
105465
105605
|
function invalidateResolutionOfFile(filePath) {
|
|
@@ -105531,17 +105671,19 @@ ${lanes.join("\n")}
|
|
|
105531
105671
|
return invalidated;
|
|
105532
105672
|
}
|
|
105533
105673
|
function canInvalidateFailedLookupResolution(resolution) {
|
|
105674
|
+
var _a2;
|
|
105534
105675
|
if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
|
|
105535
105676
|
return true;
|
|
105536
105677
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
|
|
105537
105678
|
return false;
|
|
105538
|
-
return resolution.failedLookupLocations.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
|
|
105679
|
+
return (_a2 = resolution.failedLookupLocations) == null ? void 0 : _a2.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
|
|
105539
105680
|
}
|
|
105540
105681
|
function isInvalidatedFailedLookup(locationPath) {
|
|
105541
105682
|
return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || emptyIterator, (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || emptyIterator, (fileOrDirectoryPath) => isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : void 0);
|
|
105542
105683
|
}
|
|
105543
105684
|
function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
|
|
105544
|
-
|
|
105685
|
+
var _a2;
|
|
105686
|
+
return !!affectingPathChecks && ((_a2 = resolution.affectingLocations) == null ? void 0 : _a2.some((location) => affectingPathChecks.has(location)));
|
|
105545
105687
|
}
|
|
105546
105688
|
function closeTypeRootsWatch() {
|
|
105547
105689
|
clearMap(typeRootsWatches, closeFileWatcher);
|
|
@@ -106022,7 +106164,6 @@ ${lanes.join("\n")}
|
|
|
106022
106164
|
getEnvironmentVariable: maybeBind(host, host.getEnvironmentVariable) || (() => ""),
|
|
106023
106165
|
createHash: maybeBind(host, host.createHash),
|
|
106024
106166
|
readDirectory: maybeBind(host, host.readDirectory),
|
|
106025
|
-
disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
|
|
106026
106167
|
storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit
|
|
106027
106168
|
};
|
|
106028
106169
|
return compilerHost;
|
|
@@ -106089,7 +106230,6 @@ ${lanes.join("\n")}
|
|
|
106089
106230
|
writeFile: (path, data, writeByteOrderMark) => system.writeFile(path, data, writeByteOrderMark),
|
|
106090
106231
|
createHash: maybeBind(system, system.createHash),
|
|
106091
106232
|
createProgram: createProgram2 || createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
106092
|
-
disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
|
|
106093
106233
|
storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
|
|
106094
106234
|
now: maybeBind(system, system.now)
|
|
106095
106235
|
};
|
|
@@ -106230,7 +106370,6 @@ ${lanes.join("\n")}
|
|
|
106230
106370
|
function createIncrementalCompilerHost(options, system = sys) {
|
|
106231
106371
|
const host = createCompilerHostWorker(options, void 0, system);
|
|
106232
106372
|
host.createHash = maybeBind(system, system.createHash);
|
|
106233
|
-
host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
|
|
106234
106373
|
host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
|
|
106235
106374
|
setGetSourceFileAsHashVersioned(host);
|
|
106236
106375
|
changeCompilerHostLikeToUseCache(host, (fileName) => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName));
|
|
@@ -106346,10 +106485,18 @@ ${lanes.join("\n")}
|
|
|
106346
106485
|
configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory,
|
|
106347
106486
|
false
|
|
106348
106487
|
);
|
|
106349
|
-
compilerHost.
|
|
106350
|
-
compilerHost.
|
|
106351
|
-
compilerHost.
|
|
106352
|
-
|
|
106488
|
+
compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
|
|
106489
|
+
compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
|
|
106490
|
+
if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
|
|
106491
|
+
compilerHost.resolveModuleNameLiterals = resolutionCache.resolveModuleNameLiterals.bind(resolutionCache);
|
|
106492
|
+
}
|
|
106493
|
+
compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
|
|
106494
|
+
compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
|
|
106495
|
+
if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
|
|
106496
|
+
compilerHost.resolveTypeReferenceDirectiveReferences = resolutionCache.resolveTypeReferenceDirectiveReferences.bind(resolutionCache);
|
|
106497
|
+
}
|
|
106498
|
+
compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.getModuleResolutionCache();
|
|
106499
|
+
const userProvidedResolution = !!host.resolveModuleNameLiterals || !!host.resolveTypeReferenceDirectiveReferences || !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
106353
106500
|
const customHasInvalidatedResolutions = userProvidedResolution ? maybeBind(host, host.hasInvalidatedResolutions) || returnTrue : returnFalse;
|
|
106354
106501
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
106355
106502
|
synchronizeProgram();
|
|
@@ -107020,19 +107167,38 @@ ${lanes.join("\n")}
|
|
|
107020
107167
|
const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions);
|
|
107021
107168
|
setGetSourceFileAsHashVersioned(compilerHost);
|
|
107022
107169
|
compilerHost.getParsedCommandLine = (fileName) => parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName));
|
|
107170
|
+
compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
|
|
107171
|
+
compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
|
|
107023
107172
|
compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
|
|
107024
107173
|
compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
|
|
107025
107174
|
compilerHost.getModuleResolutionCache = maybeBind(host, host.getModuleResolutionCache);
|
|
107026
|
-
|
|
107027
|
-
|
|
107028
|
-
|
|
107029
|
-
|
|
107030
|
-
|
|
107175
|
+
let moduleResolutionCache, typeReferenceDirectiveResolutionCache;
|
|
107176
|
+
if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
|
|
107177
|
+
moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName);
|
|
107178
|
+
compilerHost.resolveModuleNameLiterals = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
|
|
107179
|
+
moduleNames,
|
|
107180
|
+
containingFile,
|
|
107181
|
+
redirectedReference,
|
|
107182
|
+
options2,
|
|
107183
|
+
containingSourceFile,
|
|
107184
|
+
host,
|
|
107185
|
+
moduleResolutionCache,
|
|
107186
|
+
createModuleResolutionLoader
|
|
107187
|
+
);
|
|
107031
107188
|
compilerHost.getModuleResolutionCache = () => moduleResolutionCache;
|
|
107032
107189
|
}
|
|
107033
|
-
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
107034
|
-
|
|
107035
|
-
compilerHost.
|
|
107190
|
+
if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
|
|
107191
|
+
typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
|
|
107192
|
+
compilerHost.resolveTypeReferenceDirectiveReferences = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
|
|
107193
|
+
typeDirectiveNames,
|
|
107194
|
+
containingFile,
|
|
107195
|
+
redirectedReference,
|
|
107196
|
+
options2,
|
|
107197
|
+
containingSourceFile,
|
|
107198
|
+
host,
|
|
107199
|
+
typeReferenceDirectiveResolutionCache,
|
|
107200
|
+
createTypeReferenceResolutionLoader
|
|
107201
|
+
);
|
|
107036
107202
|
}
|
|
107037
107203
|
compilerHost.getBuildInfo = (fileName, configFilePath) => getBuildInfo3(state, fileName, toResolvedConfigFilePath(state, configFilePath), void 0);
|
|
107038
107204
|
const { watchFile: watchFile2, watchDirectory, writeLog } = createWatchFactory(hostWithWatch, options);
|
|
@@ -114081,13 +114247,14 @@ ${lanes.join("\n")}
|
|
|
114081
114247
|
return ensurePathIsNonModuleName(combineNormal(pathA, pathB));
|
|
114082
114248
|
}
|
|
114083
114249
|
function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) {
|
|
114250
|
+
var _a2;
|
|
114084
114251
|
if (importedModuleSymbol) {
|
|
114085
114252
|
const oldFileName = find(importedModuleSymbol.declarations, isSourceFile).fileName;
|
|
114086
114253
|
const newFileName = oldToNew(oldFileName);
|
|
114087
114254
|
return newFileName === void 0 ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true };
|
|
114088
114255
|
} else {
|
|
114089
114256
|
const mode = getModeForUsageLocation(importingSourceFile, importLiteral);
|
|
114090
|
-
const resolved = host.resolveModuleNames ?
|
|
114257
|
+
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? (_a2 = importingSourceFile.resolvedModules) == null ? void 0 : _a2.get(importLiteral.text, mode) : host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
|
114091
114258
|
return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
|
|
114092
114259
|
}
|
|
114093
114260
|
}
|
|
@@ -116408,6 +116575,8 @@ ${lanes.join("\n")}
|
|
|
116408
116575
|
getModuleResolutionCache: maybeBind(host, host.getModuleResolutionCache),
|
|
116409
116576
|
createHash: maybeBind(host, host.createHash),
|
|
116410
116577
|
resolveTypeReferenceDirectives: maybeBind(host, host.resolveTypeReferenceDirectives),
|
|
116578
|
+
resolveModuleNameLiterals: maybeBind(host, host.resolveModuleNameLiterals),
|
|
116579
|
+
resolveTypeReferenceDirectiveReferences: maybeBind(host, host.resolveTypeReferenceDirectiveReferences),
|
|
116411
116580
|
useSourceOfProjectReferenceRedirect: maybeBind(host, host.useSourceOfProjectReferenceRedirect),
|
|
116412
116581
|
getParsedCommandLine
|
|
116413
116582
|
};
|
|
@@ -124604,6 +124773,7 @@ ${lanes.join("\n")}
|
|
|
124604
124773
|
|
|
124605
124774
|
// src/services/codefixes/fixAddMissingMember.ts
|
|
124606
124775
|
function getInfo7(sourceFile, tokenPos, errorCode, checker, program) {
|
|
124776
|
+
var _a2;
|
|
124607
124777
|
const token = getTokenAtPosition(sourceFile, tokenPos);
|
|
124608
124778
|
const parent2 = token.parent;
|
|
124609
124779
|
if (errorCode === Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) {
|
|
@@ -124639,7 +124809,7 @@ ${lanes.join("\n")}
|
|
|
124639
124809
|
return { kind: 4 /* JsxAttributes */, token, attributes, parentDeclaration: token.parent };
|
|
124640
124810
|
}
|
|
124641
124811
|
if (isIdentifier(token)) {
|
|
124642
|
-
const type = checker.getContextualType(token);
|
|
124812
|
+
const type = (_a2 = checker.getContextualType(token)) == null ? void 0 : _a2.getNonNullableType();
|
|
124643
124813
|
if (type && getObjectFlags(type) & 16 /* Anonymous */) {
|
|
124644
124814
|
const signature = firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
|
|
124645
124815
|
if (signature === void 0)
|
|
@@ -129510,6 +129680,7 @@ ${lanes.join("\n")}
|
|
|
129510
129680
|
isTypeOnlyLocation,
|
|
129511
129681
|
isJsxIdentifierExpected,
|
|
129512
129682
|
isRightOfOpenTag,
|
|
129683
|
+
isRightOfDotOrQuestionDot,
|
|
129513
129684
|
importStatementCompletion,
|
|
129514
129685
|
insideJsDocTagTypeExpression,
|
|
129515
129686
|
symbolToSortTextMap,
|
|
@@ -129575,7 +129746,7 @@ ${lanes.join("\n")}
|
|
|
129575
129746
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
|
|
129576
129747
|
}
|
|
129577
129748
|
let caseBlock;
|
|
129578
|
-
if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
|
|
129749
|
+
if (preferences.includeCompletionsWithInsertText && contextToken && !isRightOfOpenTag && !isRightOfDotOrQuestionDot && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
|
|
129579
129750
|
const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
|
|
129580
129751
|
if (cases) {
|
|
129581
129752
|
entries.push(cases.entry);
|
|
@@ -130946,6 +131117,7 @@ ${lanes.join("\n")}
|
|
|
130946
131117
|
isTypeOnlyLocation,
|
|
130947
131118
|
isJsxIdentifierExpected,
|
|
130948
131119
|
isRightOfOpenTag,
|
|
131120
|
+
isRightOfDotOrQuestionDot: isRightOfDot || isRightOfQuestionDot,
|
|
130949
131121
|
importStatementCompletion,
|
|
130950
131122
|
hasUnresolvedAutoImports,
|
|
130951
131123
|
flags
|
|
@@ -133509,6 +133681,7 @@ ${lanes.join("\n")}
|
|
|
133509
133681
|
});
|
|
133510
133682
|
}
|
|
133511
133683
|
function findModuleReferences(program, sourceFiles, searchModuleSymbol) {
|
|
133684
|
+
var _a2;
|
|
133512
133685
|
const refs = [];
|
|
133513
133686
|
const checker = program.getTypeChecker();
|
|
133514
133687
|
for (const referencingFile of sourceFiles) {
|
|
@@ -133520,7 +133693,7 @@ ${lanes.join("\n")}
|
|
|
133520
133693
|
}
|
|
133521
133694
|
}
|
|
133522
133695
|
for (const ref of referencingFile.typeReferenceDirectives) {
|
|
133523
|
-
const referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
|
|
133696
|
+
const referenced = (_a2 = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat)) == null ? void 0 : _a2.resolvedTypeReferenceDirective;
|
|
133524
133697
|
if (referenced !== void 0 && referenced.resolvedFileName === searchSourceFile.fileName) {
|
|
133525
133698
|
refs.push({ kind: "reference", referencingFile, ref });
|
|
133526
133699
|
}
|
|
@@ -134231,7 +134404,7 @@ ${lanes.join("\n")}
|
|
|
134231
134404
|
})(FindReferencesUse || {});
|
|
134232
134405
|
((Core2) => {
|
|
134233
134406
|
function getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options = {}, sourceFilesSet = new Set(sourceFiles.map((f) => f.fileName))) {
|
|
134234
|
-
var _a2, _b;
|
|
134407
|
+
var _a2, _b, _c;
|
|
134235
134408
|
node = getAdjustedNode(node, options);
|
|
134236
134409
|
if (isSourceFile(node)) {
|
|
134237
134410
|
const resolvedRef = ts_GoToDefinition_exports.getReferenceAtPosition(node, position, program);
|
|
@@ -134263,7 +134436,7 @@ ${lanes.join("\n")}
|
|
|
134263
134436
|
if (!options.implementations && isStringLiteralLike(node)) {
|
|
134264
134437
|
if (isModuleSpecifierLike(node)) {
|
|
134265
134438
|
const fileIncludeReasons = program.getFileIncludeReasons();
|
|
134266
|
-
const referencedFileName = (_b = (_a2 = node.getSourceFile().resolvedModules) == null ? void 0 : _a2.get(node.text, getModeForUsageLocation(node.getSourceFile(), node))) == null ? void 0 : _b.resolvedFileName;
|
|
134439
|
+
const referencedFileName = (_c = (_b = (_a2 = node.getSourceFile().resolvedModules) == null ? void 0 : _a2.get(node.text, getModeForUsageLocation(node.getSourceFile(), node))) == null ? void 0 : _b.resolvedModule) == null ? void 0 : _c.resolvedFileName;
|
|
134267
134440
|
const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : void 0;
|
|
134268
134441
|
if (referencedFile) {
|
|
134269
134442
|
return [{ definition: { type: 4 /* String */, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }];
|
|
@@ -135508,7 +135681,7 @@ ${lanes.join("\n")}
|
|
|
135508
135681
|
|
|
135509
135682
|
// src/services/goToDefinition.ts
|
|
135510
135683
|
function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) {
|
|
135511
|
-
var _a2;
|
|
135684
|
+
var _a2, _b;
|
|
135512
135685
|
const resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
135513
135686
|
const fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || emptyArray;
|
|
135514
135687
|
if (resolvedRef == null ? void 0 : resolvedRef.file) {
|
|
@@ -135554,7 +135727,7 @@ ${lanes.join("\n")}
|
|
|
135554
135727
|
}
|
|
135555
135728
|
}
|
|
135556
135729
|
if (!symbol && isModuleSpecifierLike(fallbackNode)) {
|
|
135557
|
-
const ref = (_a2 = sourceFile.resolvedModules) == null ? void 0 : _a2.get(fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode));
|
|
135730
|
+
const ref = (_b = (_a2 = sourceFile.resolvedModules) == null ? void 0 : _a2.get(fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode))) == null ? void 0 : _b.resolvedModule;
|
|
135558
135731
|
if (ref) {
|
|
135559
135732
|
return [{
|
|
135560
135733
|
name: fallbackNode.text,
|
|
@@ -135632,7 +135805,7 @@ ${lanes.join("\n")}
|
|
|
135632
135805
|
return getDefinitionFromSymbol(typeChecker, symbol, node);
|
|
135633
135806
|
}
|
|
135634
135807
|
function getReferenceAtPosition(sourceFile, position, program) {
|
|
135635
|
-
var _a2, _b;
|
|
135808
|
+
var _a2, _b, _c, _d;
|
|
135636
135809
|
const referencePath = findReferenceInPosition(sourceFile.referencedFiles, position);
|
|
135637
135810
|
if (referencePath) {
|
|
135638
135811
|
const file = program.getSourceFileFromReference(sourceFile, referencePath);
|
|
@@ -135640,7 +135813,7 @@ ${lanes.join("\n")}
|
|
|
135640
135813
|
}
|
|
135641
135814
|
const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
|
135642
135815
|
if (typeReferenceDirective) {
|
|
135643
|
-
const reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
|
|
135816
|
+
const reference = (_a2 = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat)) == null ? void 0 : _a2.resolvedTypeReferenceDirective;
|
|
135644
135817
|
const file = reference && program.getSourceFile(reference.resolvedFileName);
|
|
135645
135818
|
return file && { reference: typeReferenceDirective, fileName: file.fileName, file, unverified: false };
|
|
135646
135819
|
}
|
|
@@ -135649,10 +135822,10 @@ ${lanes.join("\n")}
|
|
|
135649
135822
|
const file = program.getLibFileFromReference(libReferenceDirective);
|
|
135650
135823
|
return file && { reference: libReferenceDirective, fileName: file.fileName, file, unverified: false };
|
|
135651
135824
|
}
|
|
135652
|
-
if ((
|
|
135825
|
+
if ((_b = sourceFile.resolvedModules) == null ? void 0 : _b.size()) {
|
|
135653
135826
|
const node = getTouchingToken(sourceFile, position);
|
|
135654
135827
|
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, getModeForUsageLocation(sourceFile, node))) {
|
|
135655
|
-
const verifiedFileName = (
|
|
135828
|
+
const verifiedFileName = (_d = (_c = sourceFile.resolvedModules.get(node.text, getModeForUsageLocation(sourceFile, node))) == null ? void 0 : _c.resolvedModule) == null ? void 0 : _d.resolvedFileName;
|
|
135656
135829
|
const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
|
|
135657
135830
|
return {
|
|
135658
135831
|
file: program.getSourceFile(fileName),
|
|
@@ -137882,7 +138055,8 @@ ${lanes.join("\n")}
|
|
|
137882
138055
|
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
|
|
137883
138056
|
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(id.name, void 0))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
137884
138057
|
}
|
|
137885
|
-
function doTypedefChange(changes,
|
|
138058
|
+
function doTypedefChange(changes, context, file, name, info) {
|
|
138059
|
+
var _a2;
|
|
137886
138060
|
const { enclosingNode, selection, typeParameters } = info;
|
|
137887
138061
|
setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
137888
138062
|
const node = factory.createJSDocTypedefTag(
|
|
@@ -137904,7 +138078,7 @@ ${lanes.join("\n")}
|
|
|
137904
138078
|
const jsDoc = factory.createJSDocComment(void 0, factory.createNodeArray(concatenate(templates, [node])));
|
|
137905
138079
|
if (isJSDoc(enclosingNode)) {
|
|
137906
138080
|
const pos = enclosingNode.getStart(file);
|
|
137907
|
-
const newLineCharacter =
|
|
138081
|
+
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, (_a2 = context.formatContext) == null ? void 0 : _a2.options);
|
|
137908
138082
|
changes.insertNodeAt(file, enclosingNode.getStart(file), jsDoc, {
|
|
137909
138083
|
suffix: newLineCharacter + newLineCharacter + file.text.slice(getPrecedingNonSpaceCharacterPosition(file.text, pos - 1), pos)
|
|
137910
138084
|
});
|
|
@@ -137969,7 +138143,7 @@ ${lanes.join("\n")}
|
|
|
137969
138143
|
return emptyArray;
|
|
137970
138144
|
},
|
|
137971
138145
|
getEditsForAction: function getRefactorEditsToExtractType(context, actionName2) {
|
|
137972
|
-
const { file
|
|
138146
|
+
const { file } = context;
|
|
137973
138147
|
const info = getRangeToExtract(context);
|
|
137974
138148
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected to find a range to extract");
|
|
137975
138149
|
const name = getUniqueName("NewType", file);
|
|
@@ -137980,7 +138154,7 @@ ${lanes.join("\n")}
|
|
|
137980
138154
|
return doTypeAliasChange(changes, file, name, info);
|
|
137981
138155
|
case extractToTypeDefAction.name:
|
|
137982
138156
|
Debug.assert(info.isJS, "Invalid actionName/JS combo");
|
|
137983
|
-
return doTypedefChange(changes,
|
|
138157
|
+
return doTypedefChange(changes, context, file, name, info);
|
|
137984
138158
|
case extractToInterfaceAction.name:
|
|
137985
138159
|
Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo");
|
|
137986
138160
|
return doInterfaceChange(changes, file, name, info);
|
|
@@ -138038,10 +138212,17 @@ ${lanes.join("\n")}
|
|
|
138038
138212
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
138039
138213
|
const currentDirectory = getDirectoryPath(oldFile.fileName);
|
|
138040
138214
|
const extension = extensionFromPath(oldFile.fileName);
|
|
138041
|
-
const
|
|
138042
|
-
|
|
138043
|
-
|
|
138044
|
-
|
|
138215
|
+
const newFilename = combinePaths(
|
|
138216
|
+
currentDirectory,
|
|
138217
|
+
makeUniqueFilename(
|
|
138218
|
+
inferNewFilename(usage.oldFileImportsFromNewFile, usage.movedSymbols),
|
|
138219
|
+
extension,
|
|
138220
|
+
currentDirectory,
|
|
138221
|
+
host
|
|
138222
|
+
)
|
|
138223
|
+
) + extension;
|
|
138224
|
+
changes.createNewFile(oldFile, newFilename, getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences));
|
|
138225
|
+
addNewFileToTsconfig(program, changes, oldFile.fileName, newFilename, hostGetCanonicalFileName(host));
|
|
138045
138226
|
}
|
|
138046
138227
|
function getStatementsToMove(context) {
|
|
138047
138228
|
const rangeToMove = getRangeToMove(context);
|
|
@@ -138084,7 +138265,7 @@ ${lanes.join("\n")}
|
|
|
138084
138265
|
changes.insertNodeInListAfter(cfg, last(filesProp.initializer.elements), factory.createStringLiteral(newFilePath), filesProp.initializer.elements);
|
|
138085
138266
|
}
|
|
138086
138267
|
}
|
|
138087
|
-
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program,
|
|
138268
|
+
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences) {
|
|
138088
138269
|
const checker = program.getTypeChecker();
|
|
138089
138270
|
const prologueDirectives = takeWhile(oldFile.statements, isPrologueDirective);
|
|
138090
138271
|
if (oldFile.externalModuleIndicator === void 0 && oldFile.commonJsModuleIndicator === void 0 && usage.oldImportsNeededByNewFile.size() === 0) {
|
|
@@ -138093,14 +138274,14 @@ ${lanes.join("\n")}
|
|
|
138093
138274
|
}
|
|
138094
138275
|
const useEsModuleSyntax = !!oldFile.externalModuleIndicator;
|
|
138095
138276
|
const quotePreference = getQuotePreference(oldFile, preferences);
|
|
138096
|
-
const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile,
|
|
138277
|
+
const importsFromNewFile = createOldFileImportsFromNewFile(oldFile, usage.oldFileImportsFromNewFile, newFilename, program, host, useEsModuleSyntax, quotePreference);
|
|
138097
138278
|
if (importsFromNewFile) {
|
|
138098
138279
|
insertImports(changes, oldFile, importsFromNewFile, true);
|
|
138099
138280
|
}
|
|
138100
138281
|
deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
|
|
138101
138282
|
deleteMovedStatements(oldFile, toMove.ranges, changes);
|
|
138102
|
-
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols,
|
|
138103
|
-
const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
|
|
138283
|
+
updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, newFilename);
|
|
138284
|
+
const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference);
|
|
138104
138285
|
const body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
|
|
138105
138286
|
if (imports.length && body.length) {
|
|
138106
138287
|
return [
|
|
@@ -138128,7 +138309,7 @@ ${lanes.join("\n")}
|
|
|
138128
138309
|
forEachImportInStatement(statement, (i) => deleteUnusedImports(oldFile, i, changes, (name) => toDelete.has(checker.getSymbolAtLocation(name))));
|
|
138129
138310
|
}
|
|
138130
138311
|
}
|
|
138131
|
-
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols,
|
|
138312
|
+
function updateImportsInOtherFiles(changes, program, host, oldFile, movedSymbols, newFilename) {
|
|
138132
138313
|
const checker = program.getTypeChecker();
|
|
138133
138314
|
for (const sourceFile of program.getSourceFiles()) {
|
|
138134
138315
|
if (sourceFile === oldFile)
|
|
@@ -138142,13 +138323,14 @@ ${lanes.join("\n")}
|
|
|
138142
138323
|
return !!symbol && movedSymbols.has(symbol);
|
|
138143
138324
|
};
|
|
138144
138325
|
deleteUnusedImports(sourceFile, importNode, changes, shouldMove);
|
|
138145
|
-
const
|
|
138326
|
+
const pathToNewFileWithExtension = resolvePath(getDirectoryPath(oldFile.path), newFilename);
|
|
138327
|
+
const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToNewFileWithExtension, createModuleSpecifierResolutionHost(program, host));
|
|
138146
138328
|
const newImportDeclaration = filterImport(importNode, factory.createStringLiteral(newModuleSpecifier), shouldMove);
|
|
138147
138329
|
if (newImportDeclaration)
|
|
138148
138330
|
changes.insertNodeAfter(sourceFile, statement, newImportDeclaration);
|
|
138149
138331
|
const ns = getNamespaceLikeImport(importNode);
|
|
138150
138332
|
if (ns)
|
|
138151
|
-
updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols,
|
|
138333
|
+
updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleSpecifier, ns, importNode);
|
|
138152
138334
|
});
|
|
138153
138335
|
}
|
|
138154
138336
|
}
|
|
@@ -138165,8 +138347,8 @@ ${lanes.join("\n")}
|
|
|
138165
138347
|
return Debug.assertNever(node, `Unexpected node kind ${node.kind}`);
|
|
138166
138348
|
}
|
|
138167
138349
|
}
|
|
138168
|
-
function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols,
|
|
138169
|
-
const preferredNewNamespaceName = ts_codefix_exports.moduleSpecifierToValidIdentifier(
|
|
138350
|
+
function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleSpecifier, oldImportId, oldImportNode) {
|
|
138351
|
+
const preferredNewNamespaceName = ts_codefix_exports.moduleSpecifierToValidIdentifier(newModuleSpecifier, 99 /* ESNext */);
|
|
138170
138352
|
let needUniqueName = false;
|
|
138171
138353
|
const toChange = [];
|
|
138172
138354
|
ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, (ref) => {
|
|
@@ -138182,7 +138364,7 @@ ${lanes.join("\n")}
|
|
|
138182
138364
|
for (const ref of toChange) {
|
|
138183
138365
|
changes.replaceNode(sourceFile, ref, factory.createIdentifier(newNamespaceName));
|
|
138184
138366
|
}
|
|
138185
|
-
changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode,
|
|
138367
|
+
changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, preferredNewNamespaceName, newModuleSpecifier));
|
|
138186
138368
|
}
|
|
138187
138369
|
}
|
|
138188
138370
|
function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) {
|
|
@@ -138223,7 +138405,7 @@ ${lanes.join("\n")}
|
|
|
138223
138405
|
}
|
|
138224
138406
|
}
|
|
138225
138407
|
}
|
|
138226
|
-
function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports, quotePreference) {
|
|
138408
|
+
function createOldFileImportsFromNewFile(sourceFile, newFileNeedExport, newFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
|
|
138227
138409
|
let defaultImport;
|
|
138228
138410
|
const imports = [];
|
|
138229
138411
|
newFileNeedExport.forEach((symbol) => {
|
|
@@ -138233,17 +138415,18 @@ ${lanes.join("\n")}
|
|
|
138233
138415
|
imports.push(symbol.name);
|
|
138234
138416
|
}
|
|
138235
138417
|
});
|
|
138236
|
-
return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, quotePreference);
|
|
138418
|
+
return makeImportOrRequire(sourceFile, defaultImport, imports, newFileNameWithExtension, program, host, useEs6Imports, quotePreference);
|
|
138237
138419
|
}
|
|
138238
|
-
function makeImportOrRequire(defaultImport, imports,
|
|
138239
|
-
|
|
138420
|
+
function makeImportOrRequire(sourceFile, defaultImport, imports, newFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
|
|
138421
|
+
const pathToNewFile = resolvePath(getDirectoryPath(sourceFile.path), newFileNameWithExtension);
|
|
138422
|
+
const pathToNewFileWithCorrectExtension = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToNewFile, createModuleSpecifierResolutionHost(program, host));
|
|
138240
138423
|
if (useEs6Imports) {
|
|
138241
138424
|
const specifiers = imports.map((i) => factory.createImportSpecifier(false, void 0, factory.createIdentifier(i)));
|
|
138242
|
-
return makeImportIfNecessary(defaultImport, specifiers,
|
|
138425
|
+
return makeImportIfNecessary(defaultImport, specifiers, pathToNewFileWithCorrectExtension, quotePreference);
|
|
138243
138426
|
} else {
|
|
138244
138427
|
Debug.assert(!defaultImport, "No default import should exist");
|
|
138245
138428
|
const bindingElements = imports.map((i) => factory.createBindingElement(void 0, void 0, i));
|
|
138246
|
-
return bindingElements.length ? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), void 0, createRequireCall(factory.createStringLiteral(
|
|
138429
|
+
return bindingElements.length ? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), void 0, createRequireCall(factory.createStringLiteral(pathToNewFileWithCorrectExtension))) : void 0;
|
|
138247
138430
|
}
|
|
138248
138431
|
}
|
|
138249
138432
|
function makeVariableStatement(name, type, initializer, flags = 2 /* Const */) {
|
|
@@ -138340,7 +138523,7 @@ ${lanes.join("\n")}
|
|
|
138340
138523
|
break;
|
|
138341
138524
|
}
|
|
138342
138525
|
}
|
|
138343
|
-
function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) {
|
|
138526
|
+
function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference) {
|
|
138344
138527
|
const copiedOldImports = [];
|
|
138345
138528
|
for (const oldStatement of oldFile.statements) {
|
|
138346
138529
|
forEachImportInStatement(oldStatement, (i) => {
|
|
@@ -138371,19 +138554,19 @@ ${lanes.join("\n")}
|
|
|
138371
138554
|
}
|
|
138372
138555
|
}
|
|
138373
138556
|
});
|
|
138374
|
-
append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports,
|
|
138557
|
+
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
138375
138558
|
return copiedOldImports;
|
|
138376
138559
|
}
|
|
138377
|
-
function
|
|
138378
|
-
let
|
|
138560
|
+
function makeUniqueFilename(proposedFilename, extension, inDirectory, host) {
|
|
138561
|
+
let newFilename = proposedFilename;
|
|
138379
138562
|
for (let i = 1; ; i++) {
|
|
138380
|
-
const name = combinePaths(inDirectory,
|
|
138563
|
+
const name = combinePaths(inDirectory, newFilename + extension);
|
|
138381
138564
|
if (!host.fileExists(name))
|
|
138382
|
-
return
|
|
138383
|
-
|
|
138565
|
+
return newFilename;
|
|
138566
|
+
newFilename = `${proposedFilename}.${i}`;
|
|
138384
138567
|
}
|
|
138385
138568
|
}
|
|
138386
|
-
function
|
|
138569
|
+
function inferNewFilename(importsFromNewFile, movedSymbols) {
|
|
138387
138570
|
return importsFromNewFile.forEachEntry(symbolNameNoDefault) || movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile";
|
|
138388
138571
|
}
|
|
138389
138572
|
function getUsageInfo(oldFile, toMove, checker) {
|
|
@@ -138657,6 +138840,7 @@ ${lanes.join("\n")}
|
|
|
138657
138840
|
var init_moveToNewFile = __esm({
|
|
138658
138841
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
138659
138842
|
"use strict";
|
|
138843
|
+
init_moduleSpecifiers();
|
|
138660
138844
|
init_ts4();
|
|
138661
138845
|
init_ts_refactor();
|
|
138662
138846
|
refactorName4 = "Move to a new file";
|
|
@@ -149032,6 +149216,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
149032
149216
|
createModuleBlock: () => createModuleBlock,
|
|
149033
149217
|
createModuleDeclaration: () => createModuleDeclaration,
|
|
149034
149218
|
createModuleResolutionCache: () => createModuleResolutionCache,
|
|
149219
|
+
createModuleResolutionLoader: () => createModuleResolutionLoader,
|
|
149035
149220
|
createModuleSpecifierResolutionHost: () => createModuleSpecifierResolutionHost,
|
|
149036
149221
|
createMultiMap: () => createMultiMap,
|
|
149037
149222
|
createNamedExports: () => createNamedExports,
|
|
@@ -149154,6 +149339,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
149154
149339
|
createTypeQueryNode: () => createTypeQueryNode,
|
|
149155
149340
|
createTypeReferenceDirectiveResolutionCache: () => createTypeReferenceDirectiveResolutionCache,
|
|
149156
149341
|
createTypeReferenceNode: () => createTypeReferenceNode,
|
|
149342
|
+
createTypeReferenceResolutionLoader: () => createTypeReferenceResolutionLoader,
|
|
149157
149343
|
createUnderscoreEscapedMultiMap: () => createUnderscoreEscapedMultiMap,
|
|
149158
149344
|
createUnionTypeNode: () => createUnionTypeNode,
|
|
149159
149345
|
createUniqueName: () => createUniqueName,
|
|
@@ -149643,9 +149829,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
149643
149829
|
getRenameLocation: () => getRenameLocation,
|
|
149644
149830
|
getReplacementSpanForContextToken: () => getReplacementSpanForContextToken,
|
|
149645
149831
|
getResolutionDiagnostic: () => getResolutionDiagnostic,
|
|
149646
|
-
getResolutionMode: () => getResolutionMode,
|
|
149647
149832
|
getResolutionModeOverrideForClause: () => getResolutionModeOverrideForClause,
|
|
149648
|
-
getResolutionName: () => getResolutionName,
|
|
149649
149833
|
getResolvedExternalModuleName: () => getResolvedExternalModuleName,
|
|
149650
149834
|
getResolvedModule: () => getResolvedModule,
|
|
149651
149835
|
getResolvedTypeReferenceDirective: () => getResolvedTypeReferenceDirective,
|
|
@@ -150464,7 +150648,6 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
150464
150648
|
listFiles: () => listFiles,
|
|
150465
150649
|
loadModuleFromGlobalCache: () => loadModuleFromGlobalCache,
|
|
150466
150650
|
loadWithModeAwareCache: () => loadWithModeAwareCache,
|
|
150467
|
-
loadWithTypeDirectiveCache: () => loadWithTypeDirectiveCache,
|
|
150468
150651
|
makeIdentifierFromModuleName: () => makeIdentifierFromModuleName,
|
|
150469
150652
|
makeImport: () => makeImport,
|
|
150470
150653
|
makeImportIfNecessary: () => makeImportIfNecessary,
|
|
@@ -150496,6 +150679,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
150496
150679
|
modifiersToFlags: () => modifiersToFlags,
|
|
150497
150680
|
moduleOptionDeclaration: () => moduleOptionDeclaration,
|
|
150498
150681
|
moduleResolutionIsEqualTo: () => moduleResolutionIsEqualTo,
|
|
150682
|
+
moduleResolutionNameAndModeGetter: () => moduleResolutionNameAndModeGetter,
|
|
150499
150683
|
moduleResolutionOptionDeclarations: () => moduleResolutionOptionDeclarations,
|
|
150500
150684
|
moduleResolutionRespectsExports: () => moduleResolutionRespectsExports,
|
|
150501
150685
|
moduleResolutionUsesNodeModules: () => moduleResolutionUsesNodeModules,
|
|
@@ -150872,6 +151056,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
150872
151056
|
typeHasCallOrConstructSignatures: () => typeHasCallOrConstructSignatures,
|
|
150873
151057
|
typeKeywords: () => typeKeywords,
|
|
150874
151058
|
typeParameterNamePart: () => typeParameterNamePart,
|
|
151059
|
+
typeReferenceResolutionNameAndModeGetter: () => typeReferenceResolutionNameAndModeGetter,
|
|
150875
151060
|
typeToDisplayParts: () => typeToDisplayParts,
|
|
150876
151061
|
unchangedPollThresholds: () => unchangedPollThresholds,
|
|
150877
151062
|
unchangedTextChangeRange: () => unchangedTextChangeRange,
|
|
@@ -150987,6 +151172,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
150987
151172
|
updatePropertyAssignment: () => updatePropertyAssignment,
|
|
150988
151173
|
updatePropertySignature: () => updatePropertySignature,
|
|
150989
151174
|
updateQualifiedName: () => updateQualifiedName,
|
|
151175
|
+
updateResolutionField: () => updateResolutionField,
|
|
150990
151176
|
updateRestTypeNode: () => updateRestTypeNode,
|
|
150991
151177
|
updateReturn: () => updateReturn,
|
|
150992
151178
|
updateSetAccessor: () => updateSetAccessor,
|