typescript 5.0.0-dev.20221206 → 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 +174 -139
- package/lib/tsserver.js +153265 -150990
- package/lib/tsserverlibrary.d.ts +19 -6
- package/lib/tsserverlibrary.js +216 -172
- package/lib/typescript.d.ts +19 -6
- package/lib/typescript.js +216 -172
- package/lib/typingsInstaller.js +53 -70
- package/package.json +1 -1
package/lib/tsserverlibrary.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
|
}
|
|
@@ -35139,8 +35123,10 @@ ${lanes.join("\n")}
|
|
|
35139
35123
|
options = redirectedReference.commandLine.options;
|
|
35140
35124
|
}
|
|
35141
35125
|
const containingDirectory = containingFile ? getDirectoryPath(containingFile) : void 0;
|
|
35142
|
-
|
|
35143
|
-
|
|
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
|
+
}
|
|
35144
35130
|
if (result) {
|
|
35145
35131
|
if (traceEnabled) {
|
|
35146
35132
|
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -35216,7 +35202,12 @@ ${lanes.join("\n")}
|
|
|
35216
35202
|
affectingLocations: initializeResolutionField(affectingLocations),
|
|
35217
35203
|
resolutionDiagnostics: initializeResolutionField(diagnostics)
|
|
35218
35204
|
};
|
|
35219
|
-
|
|
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
|
+
}
|
|
35220
35211
|
if (traceEnabled)
|
|
35221
35212
|
traceResult(result);
|
|
35222
35213
|
return result;
|
|
@@ -35346,23 +35337,27 @@ ${lanes.join("\n")}
|
|
|
35346
35337
|
if (ownOptions)
|
|
35347
35338
|
redirectsMap.set(ownOptions, ownMap);
|
|
35348
35339
|
return {
|
|
35340
|
+
getMapOfCacheRedirects,
|
|
35349
35341
|
getOrCreateMapOfCacheRedirects,
|
|
35350
35342
|
update,
|
|
35351
35343
|
clear: clear2
|
|
35352
35344
|
};
|
|
35345
|
+
function getMapOfCacheRedirects(redirectedReference) {
|
|
35346
|
+
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, false) : ownMap;
|
|
35347
|
+
}
|
|
35353
35348
|
function getOrCreateMapOfCacheRedirects(redirectedReference) {
|
|
35354
|
-
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options) : ownMap;
|
|
35349
|
+
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options, true) : ownMap;
|
|
35355
35350
|
}
|
|
35356
35351
|
function update(newOptions) {
|
|
35357
35352
|
if (ownOptions !== newOptions) {
|
|
35358
35353
|
if (ownOptions)
|
|
35359
|
-
ownMap = getOrCreateMap(newOptions);
|
|
35354
|
+
ownMap = getOrCreateMap(newOptions, true);
|
|
35360
35355
|
else
|
|
35361
35356
|
redirectsMap.set(newOptions, ownMap);
|
|
35362
35357
|
ownOptions = newOptions;
|
|
35363
35358
|
}
|
|
35364
35359
|
}
|
|
35365
|
-
function getOrCreateMap(redirectOptions) {
|
|
35360
|
+
function getOrCreateMap(redirectOptions, create) {
|
|
35366
35361
|
let result = redirectsMap.get(redirectOptions);
|
|
35367
35362
|
if (result)
|
|
35368
35363
|
return result;
|
|
@@ -35376,9 +35371,13 @@ ${lanes.join("\n")}
|
|
|
35376
35371
|
else if (!redirectsKeyToMap.has(ownKey))
|
|
35377
35372
|
redirectsKeyToMap.set(ownKey, ownMap);
|
|
35378
35373
|
}
|
|
35379
|
-
|
|
35374
|
+
if (create)
|
|
35375
|
+
result != null ? result : result = /* @__PURE__ */ new Map();
|
|
35376
|
+
if (result)
|
|
35377
|
+
redirectsKeyToMap.set(key, result);
|
|
35380
35378
|
}
|
|
35381
|
-
|
|
35379
|
+
if (result)
|
|
35380
|
+
redirectsMap.set(redirectOptions, result);
|
|
35382
35381
|
return result;
|
|
35383
35382
|
}
|
|
35384
35383
|
function clear2() {
|
|
@@ -35430,8 +35429,10 @@ ${lanes.join("\n")}
|
|
|
35430
35429
|
}
|
|
35431
35430
|
return result;
|
|
35432
35431
|
}
|
|
35433
|
-
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName,
|
|
35432
|
+
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
|
|
35433
|
+
const directoryToModuleNameMap = createCacheWithRedirects(options);
|
|
35434
35434
|
return {
|
|
35435
|
+
getFromDirectoryCache,
|
|
35435
35436
|
getOrCreateCacheForDirectory,
|
|
35436
35437
|
clear: clear2,
|
|
35437
35438
|
update
|
|
@@ -35439,13 +35440,18 @@ ${lanes.join("\n")}
|
|
|
35439
35440
|
function clear2() {
|
|
35440
35441
|
directoryToModuleNameMap.clear();
|
|
35441
35442
|
}
|
|
35442
|
-
function update(
|
|
35443
|
-
directoryToModuleNameMap.update(
|
|
35443
|
+
function update(options2) {
|
|
35444
|
+
directoryToModuleNameMap.update(options2);
|
|
35444
35445
|
}
|
|
35445
35446
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
35446
35447
|
const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
35447
35448
|
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
|
|
35448
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
|
+
}
|
|
35449
35455
|
}
|
|
35450
35456
|
function createModeAwareCacheKey(specifier, mode) {
|
|
35451
35457
|
return mode === void 0 ? specifier : `${mode}|${specifier}`;
|
|
@@ -35494,33 +35500,32 @@ ${lanes.join("\n")}
|
|
|
35494
35500
|
}
|
|
35495
35501
|
return map2;
|
|
35496
35502
|
}
|
|
35497
|
-
function
|
|
35498
|
-
|
|
35499
|
-
|
|
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) {
|
|
35500
35510
|
const moduleNameToDirectoryMap = createCacheWithRedirects(options);
|
|
35501
|
-
const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
35502
35511
|
return {
|
|
35503
|
-
|
|
35504
|
-
|
|
35505
|
-
getOrCreateCacheForModuleName,
|
|
35512
|
+
getFromNonRelativeNameCache,
|
|
35513
|
+
getOrCreateCacheForNonRelativeName,
|
|
35506
35514
|
clear: clear2,
|
|
35507
|
-
update
|
|
35508
|
-
getPackageJsonInfoCache: () => packageJsonInfoCache,
|
|
35509
|
-
clearAllExceptPackageJsonInfoCache
|
|
35515
|
+
update
|
|
35510
35516
|
};
|
|
35511
35517
|
function clear2() {
|
|
35512
|
-
clearAllExceptPackageJsonInfoCache();
|
|
35513
|
-
packageJsonInfoCache.clear();
|
|
35514
|
-
}
|
|
35515
|
-
function clearAllExceptPackageJsonInfoCache() {
|
|
35516
|
-
perDirectoryResolutionCache.clear();
|
|
35517
35518
|
moduleNameToDirectoryMap.clear();
|
|
35518
35519
|
}
|
|
35519
35520
|
function update(options2) {
|
|
35520
|
-
directoryToModuleNameMap.update(options2);
|
|
35521
35521
|
moduleNameToDirectoryMap.update(options2);
|
|
35522
35522
|
}
|
|
35523
|
-
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) {
|
|
35524
35529
|
Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
|
|
35525
35530
|
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
|
|
35526
35531
|
}
|
|
@@ -35536,7 +35541,7 @@ ${lanes.join("\n")}
|
|
|
35536
35541
|
return;
|
|
35537
35542
|
}
|
|
35538
35543
|
directoryPathMap.set(path, result);
|
|
35539
|
-
const resolvedFileName =
|
|
35544
|
+
const resolvedFileName = getResolvedFileName(result);
|
|
35540
35545
|
const commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
|
|
35541
35546
|
let current = path;
|
|
35542
35547
|
while (current !== commonPrefix) {
|
|
@@ -35570,14 +35575,22 @@ ${lanes.join("\n")}
|
|
|
35570
35575
|
}
|
|
35571
35576
|
}
|
|
35572
35577
|
}
|
|
35573
|
-
function
|
|
35574
|
-
const
|
|
35575
|
-
const
|
|
35576
|
-
|
|
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);
|
|
35577
35587
|
return {
|
|
35578
35588
|
...packageJsonInfoCache,
|
|
35579
35589
|
...perDirectoryResolutionCache,
|
|
35590
|
+
...nonRelativeNameResolutionCache,
|
|
35580
35591
|
clear: clear2,
|
|
35592
|
+
update,
|
|
35593
|
+
getPackageJsonInfoCache: () => packageJsonInfoCache,
|
|
35581
35594
|
clearAllExceptPackageJsonInfoCache
|
|
35582
35595
|
};
|
|
35583
35596
|
function clear2() {
|
|
@@ -35586,14 +35599,36 @@ ${lanes.join("\n")}
|
|
|
35586
35599
|
}
|
|
35587
35600
|
function clearAllExceptPackageJsonInfoCache() {
|
|
35588
35601
|
perDirectoryResolutionCache.clear();
|
|
35602
|
+
nonRelativeNameResolutionCache.clear();
|
|
35603
|
+
}
|
|
35604
|
+
function update(options2) {
|
|
35605
|
+
perDirectoryResolutionCache.update(options2);
|
|
35606
|
+
nonRelativeNameResolutionCache.update(options2);
|
|
35589
35607
|
}
|
|
35590
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
|
+
);
|
|
35628
|
+
}
|
|
35591
35629
|
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
35592
35630
|
const containingDirectory = getDirectoryPath(containingFile);
|
|
35593
|
-
|
|
35594
|
-
if (!perFolderCache)
|
|
35595
|
-
return void 0;
|
|
35596
|
-
return perFolderCache.get(moduleName, mode);
|
|
35631
|
+
return cache.getFromDirectoryCache(moduleName, mode, containingDirectory, void 0);
|
|
35597
35632
|
}
|
|
35598
35633
|
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
35599
35634
|
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
@@ -35607,8 +35642,7 @@ ${lanes.join("\n")}
|
|
|
35607
35642
|
}
|
|
35608
35643
|
}
|
|
35609
35644
|
const containingDirectory = getDirectoryPath(containingFile);
|
|
35610
|
-
|
|
35611
|
-
let result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
|
|
35645
|
+
let result = cache == null ? void 0 : cache.getFromDirectoryCache(moduleName, resolutionMode, containingDirectory, redirectedReference);
|
|
35612
35646
|
if (result) {
|
|
35613
35647
|
if (traceEnabled) {
|
|
35614
35648
|
trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -35658,11 +35692,9 @@ ${lanes.join("\n")}
|
|
|
35658
35692
|
if (result && result.resolvedModule)
|
|
35659
35693
|
perfLogger.logInfoEvent(`Module "${moduleName}" resolved to "${result.resolvedModule.resolvedFileName}"`);
|
|
35660
35694
|
perfLogger.logStopResolveModule(result && result.resolvedModule ? "" + result.resolvedModule.resolvedFileName : "null");
|
|
35661
|
-
|
|
35662
|
-
|
|
35663
|
-
|
|
35664
|
-
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
35665
|
-
}
|
|
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);
|
|
35666
35698
|
}
|
|
35667
35699
|
}
|
|
35668
35700
|
if (traceEnabled) {
|
|
@@ -36641,7 +36673,7 @@ ${lanes.join("\n")}
|
|
|
36641
36673
|
return loadModuleFromNearestNodeModulesDirectoryWorker(4 /* Declaration */, moduleName, directory, state, true, void 0, void 0);
|
|
36642
36674
|
}
|
|
36643
36675
|
function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
36644
|
-
const
|
|
36676
|
+
const mode = state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */;
|
|
36645
36677
|
const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
|
|
36646
36678
|
const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
|
|
36647
36679
|
if (priorityExtensions) {
|
|
@@ -36655,7 +36687,7 @@ ${lanes.join("\n")}
|
|
|
36655
36687
|
function lookup(extensions2) {
|
|
36656
36688
|
return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
|
|
36657
36689
|
if (getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
36658
|
-
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
|
|
36690
|
+
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
|
|
36659
36691
|
if (resolutionFromCache) {
|
|
36660
36692
|
return resolutionFromCache;
|
|
36661
36693
|
}
|
|
@@ -36800,8 +36832,8 @@ ${lanes.join("\n")}
|
|
|
36800
36832
|
function unmangleScopedPackageName(typesPackageName) {
|
|
36801
36833
|
return stringContains(typesPackageName, mangledScopedPackageSeparator) ? "@" + typesPackageName.replace(mangledScopedPackageSeparator, directorySeparator) : typesPackageName;
|
|
36802
36834
|
}
|
|
36803
|
-
function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
|
|
36804
|
-
const result = cache && cache.
|
|
36835
|
+
function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
|
|
36836
|
+
const result = cache && cache.getFromNonRelativeNameCache(moduleName, mode, containingDirectory, redirectedReference);
|
|
36805
36837
|
if (result) {
|
|
36806
36838
|
if (state.traceEnabled) {
|
|
36807
36839
|
trace(state.host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -36844,9 +36876,8 @@ ${lanes.join("\n")}
|
|
|
36844
36876
|
return { value: resolvedUsingSettings };
|
|
36845
36877
|
}
|
|
36846
36878
|
if (!isExternalModuleNameRelative(moduleName)) {
|
|
36847
|
-
const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, void 0, redirectedReference);
|
|
36848
36879
|
const resolved2 = forEachAncestorDirectory(containingDirectory, (directory) => {
|
|
36849
|
-
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(
|
|
36880
|
+
const resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, void 0, directory, redirectedReference, state);
|
|
36850
36881
|
if (resolutionFromCache) {
|
|
36851
36882
|
return resolutionFromCache;
|
|
36852
36883
|
}
|
|
@@ -40258,7 +40289,7 @@ ${lanes.join("\n")}
|
|
|
40258
40289
|
if (!shortest) {
|
|
40259
40290
|
return void 0;
|
|
40260
40291
|
}
|
|
40261
|
-
return getEmitModuleResolutionKind(compilerOptions) ===
|
|
40292
|
+
return getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */ ? removeFileExtension(shortest) : removeExtensionAndIndexPostFix(shortest, ending, compilerOptions);
|
|
40262
40293
|
}
|
|
40263
40294
|
function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
40264
40295
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -70304,7 +70335,6 @@ ${lanes.join("\n")}
|
|
|
70304
70335
|
let firstDefaultClause;
|
|
70305
70336
|
let hasDuplicateDefaultClause = false;
|
|
70306
70337
|
const expressionType = checkExpression(node.expression);
|
|
70307
|
-
const expressionIsLiteral = isLiteralType(expressionType);
|
|
70308
70338
|
forEach(node.caseBlock.clauses, (clause) => {
|
|
70309
70339
|
if (clause.kind === 293 /* DefaultClause */ && !hasDuplicateDefaultClause) {
|
|
70310
70340
|
if (firstDefaultClause === void 0) {
|
|
@@ -70323,15 +70353,9 @@ ${lanes.join("\n")}
|
|
|
70323
70353
|
}
|
|
70324
70354
|
function createLazyCaseClauseDiagnostics(clause2) {
|
|
70325
70355
|
return () => {
|
|
70326
|
-
|
|
70327
|
-
|
|
70328
|
-
|
|
70329
|
-
if (!caseIsLiteral || !expressionIsLiteral) {
|
|
70330
|
-
caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
|
|
70331
|
-
comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
|
|
70332
|
-
}
|
|
70333
|
-
if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
|
|
70334
|
-
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);
|
|
70335
70359
|
}
|
|
70336
70360
|
};
|
|
70337
70361
|
}
|
|
@@ -100809,7 +100833,7 @@ ${lanes.join("\n")}
|
|
|
100809
100833
|
const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
|
100810
100834
|
const containingDir = getDirectoryPath(containingFileName);
|
|
100811
100835
|
const redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
100812
|
-
const fromCache = moduleResolutionCache.
|
|
100836
|
+
const fromCache = moduleResolutionCache.getFromNonRelativeNameCache(name, mode, containingDir, redirectedReference);
|
|
100813
100837
|
if (fromCache)
|
|
100814
100838
|
addResolutionDiagnostics(fromCache);
|
|
100815
100839
|
}
|
|
@@ -103554,6 +103578,26 @@ ${lanes.join("\n")}
|
|
|
103554
103578
|
(state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = /* @__PURE__ */ new Set())).add(path);
|
|
103555
103579
|
}
|
|
103556
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;
|
|
103557
103601
|
function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature = state.useFileVersionAsSignature) {
|
|
103558
103602
|
var _a2;
|
|
103559
103603
|
if ((_a2 = state.hasCalledUpdateShapeSignature) == null ? void 0 : _a2.has(sourceFile.resolvedPath))
|
|
@@ -103562,26 +103606,12 @@ ${lanes.join("\n")}
|
|
|
103562
103606
|
const prevSignature = info.signature;
|
|
103563
103607
|
let latestSignature;
|
|
103564
103608
|
if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
|
|
103565
|
-
programOfThisState
|
|
103566
|
-
|
|
103567
|
-
(
|
|
103568
|
-
|
|
103569
|
-
|
|
103570
|
-
|
|
103571
|
-
sourceFile,
|
|
103572
|
-
text,
|
|
103573
|
-
host,
|
|
103574
|
-
data
|
|
103575
|
-
);
|
|
103576
|
-
if (latestSignature !== prevSignature) {
|
|
103577
|
-
updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
|
|
103578
|
-
}
|
|
103579
|
-
},
|
|
103580
|
-
cancellationToken,
|
|
103581
|
-
true,
|
|
103582
|
-
void 0,
|
|
103583
|
-
true
|
|
103584
|
-
);
|
|
103609
|
+
computeDtsSignature(programOfThisState, sourceFile, cancellationToken, host, (signature, sourceFiles) => {
|
|
103610
|
+
latestSignature = signature;
|
|
103611
|
+
if (latestSignature !== prevSignature) {
|
|
103612
|
+
updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
|
|
103613
|
+
}
|
|
103614
|
+
});
|
|
103585
103615
|
}
|
|
103586
103616
|
if (latestSignature === void 0) {
|
|
103587
103617
|
latestSignature = sourceFile.version;
|
|
@@ -103605,27 +103635,24 @@ ${lanes.join("\n")}
|
|
|
103605
103635
|
if (!state.exportedModulesMap)
|
|
103606
103636
|
return;
|
|
103607
103637
|
(state.oldExportedModulesMap || (state.oldExportedModulesMap = /* @__PURE__ */ new Map())).set(sourceFile.resolvedPath, state.exportedModulesMap.getValues(sourceFile.resolvedPath) || false);
|
|
103608
|
-
|
|
103609
|
-
state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
|
|
103610
|
-
return;
|
|
103611
|
-
}
|
|
103612
|
-
let exportedModules;
|
|
103613
|
-
exportedModulesFromDeclarationEmit.forEach((symbol) => addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)));
|
|
103638
|
+
const exportedModules = getExportedModules(exportedModulesFromDeclarationEmit);
|
|
103614
103639
|
if (exportedModules) {
|
|
103615
103640
|
state.exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
|
|
103616
103641
|
} else {
|
|
103617
103642
|
state.exportedModulesMap.deleteKey(sourceFile.resolvedPath);
|
|
103618
103643
|
}
|
|
103619
|
-
function addExportedModule(exportedModulePaths) {
|
|
103620
|
-
if (exportedModulePaths == null ? void 0 : exportedModulePaths.length) {
|
|
103621
|
-
if (!exportedModules) {
|
|
103622
|
-
exportedModules = /* @__PURE__ */ new Set();
|
|
103623
|
-
}
|
|
103624
|
-
exportedModulePaths.forEach((path) => exportedModules.add(path));
|
|
103625
|
-
}
|
|
103626
|
-
}
|
|
103627
103644
|
}
|
|
103628
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;
|
|
103629
103656
|
function getAllDependencies(state, programOfThisState, sourceFile) {
|
|
103630
103657
|
const compilerOptions = programOfThisState.getCompilerOptions();
|
|
103631
103658
|
if (outFile(compilerOptions)) {
|
|
@@ -103769,9 +103796,9 @@ ${lanes.join("\n")}
|
|
|
103769
103796
|
function hasSameKeys(map1, map2) {
|
|
103770
103797
|
return map1 === map2 || map1 !== void 0 && map2 !== void 0 && map1.size === map2.size && !forEachKey(map1, (key) => !map2.has(key));
|
|
103771
103798
|
}
|
|
103772
|
-
function createBuilderProgramState(newProgram, oldState
|
|
103799
|
+
function createBuilderProgramState(newProgram, oldState) {
|
|
103773
103800
|
var _a2, _b;
|
|
103774
|
-
const state = BuilderState.create(newProgram, oldState,
|
|
103801
|
+
const state = BuilderState.create(newProgram, oldState, false);
|
|
103775
103802
|
state.program = newProgram;
|
|
103776
103803
|
const compilerOptions = newProgram.getCompilerOptions();
|
|
103777
103804
|
state.compilerOptions = compilerOptions;
|
|
@@ -104063,7 +104090,7 @@ ${lanes.join("\n")}
|
|
|
104063
104090
|
sourceFile,
|
|
104064
104091
|
cancellationToken,
|
|
104065
104092
|
host,
|
|
104066
|
-
|
|
104093
|
+
true
|
|
104067
104094
|
);
|
|
104068
104095
|
if (getEmitDeclarations(state.compilerOptions)) {
|
|
104069
104096
|
addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
|
|
@@ -104446,7 +104473,7 @@ ${lanes.join("\n")}
|
|
|
104446
104473
|
oldState = void 0;
|
|
104447
104474
|
return oldProgram;
|
|
104448
104475
|
}
|
|
104449
|
-
const state = createBuilderProgramState(newProgram, oldState
|
|
104476
|
+
const state = createBuilderProgramState(newProgram, oldState);
|
|
104450
104477
|
newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, bundle);
|
|
104451
104478
|
newProgram = void 0;
|
|
104452
104479
|
oldProgram = void 0;
|
|
@@ -104943,9 +104970,9 @@ ${lanes.join("\n")}
|
|
|
104943
104970
|
let filesWithInvalidatedResolutions;
|
|
104944
104971
|
let filesWithInvalidatedNonRelativeUnresolvedImports;
|
|
104945
104972
|
const nonRelativeExternalModuleResolutions = createMultiMap();
|
|
104946
|
-
const resolutionsWithFailedLookups =
|
|
104947
|
-
const resolutionsWithOnlyAffectingLocations =
|
|
104948
|
-
const resolvedFileToResolution =
|
|
104973
|
+
const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
|
|
104974
|
+
const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
|
|
104975
|
+
const resolvedFileToResolution = /* @__PURE__ */ new Map();
|
|
104949
104976
|
const impliedFormatPackageJsons = /* @__PURE__ */ new Map();
|
|
104950
104977
|
let hasChangedAutomaticTypeDirectiveNames = false;
|
|
104951
104978
|
let affectingPathChecksForFile;
|
|
@@ -105018,8 +105045,8 @@ ${lanes.join("\n")}
|
|
|
105018
105045
|
resolvedModuleNames.clear();
|
|
105019
105046
|
resolvedTypeReferenceDirectives.clear();
|
|
105020
105047
|
resolvedFileToResolution.clear();
|
|
105021
|
-
resolutionsWithFailedLookups.
|
|
105022
|
-
resolutionsWithOnlyAffectingLocations.
|
|
105048
|
+
resolutionsWithFailedLookups.clear();
|
|
105049
|
+
resolutionsWithOnlyAffectingLocations.clear();
|
|
105023
105050
|
failedLookupChecks = void 0;
|
|
105024
105051
|
startsWithPathChecks = void 0;
|
|
105025
105052
|
isInDirectoryChecks = void 0;
|
|
@@ -105336,12 +105363,13 @@ ${lanes.join("\n")}
|
|
|
105336
105363
|
return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
105337
105364
|
}
|
|
105338
105365
|
function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
|
|
105366
|
+
var _a2, _b;
|
|
105339
105367
|
if (resolution.refCount) {
|
|
105340
105368
|
resolution.refCount++;
|
|
105341
105369
|
Debug.assertIsDefined(resolution.files);
|
|
105342
105370
|
} else {
|
|
105343
105371
|
resolution.refCount = 1;
|
|
105344
|
-
Debug.assert(
|
|
105372
|
+
Debug.assert(!((_a2 = resolution.files) == null ? void 0 : _a2.size));
|
|
105345
105373
|
if (isExternalModuleNameRelative(name)) {
|
|
105346
105374
|
watchFailedLookupLocationOfResolution(resolution);
|
|
105347
105375
|
} else {
|
|
@@ -105349,10 +105377,14 @@ ${lanes.join("\n")}
|
|
|
105349
105377
|
}
|
|
105350
105378
|
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
105351
105379
|
if (resolved && resolved.resolvedFileName) {
|
|
105352
|
-
|
|
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);
|
|
105353
105385
|
}
|
|
105354
105386
|
}
|
|
105355
|
-
(resolution.files
|
|
105387
|
+
((_b = resolution.files) != null ? _b : resolution.files = /* @__PURE__ */ new Set()).add(filePath);
|
|
105356
105388
|
}
|
|
105357
105389
|
function watchFailedLookupLocationOfResolution(resolution) {
|
|
105358
105390
|
Debug.assert(!!resolution.refCount);
|
|
@@ -105360,7 +105392,7 @@ ${lanes.join("\n")}
|
|
|
105360
105392
|
if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length))
|
|
105361
105393
|
return;
|
|
105362
105394
|
if (failedLookupLocations == null ? void 0 : failedLookupLocations.length)
|
|
105363
|
-
resolutionsWithFailedLookups.
|
|
105395
|
+
resolutionsWithFailedLookups.add(resolution);
|
|
105364
105396
|
let setAtRoot = false;
|
|
105365
105397
|
if (failedLookupLocations) {
|
|
105366
105398
|
for (const failedLookupLocation of failedLookupLocations) {
|
|
@@ -105392,7 +105424,7 @@ ${lanes.join("\n")}
|
|
|
105392
105424
|
if (!(affectingLocations == null ? void 0 : affectingLocations.length))
|
|
105393
105425
|
return;
|
|
105394
105426
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
105395
|
-
resolutionsWithOnlyAffectingLocations.
|
|
105427
|
+
resolutionsWithOnlyAffectingLocations.add(resolution);
|
|
105396
105428
|
for (const affectingLocation of affectingLocations) {
|
|
105397
105429
|
createFileWatcherOfAffectingLocation(affectingLocation, true);
|
|
105398
105430
|
}
|
|
@@ -105471,17 +105503,20 @@ ${lanes.join("\n")}
|
|
|
105471
105503
|
}
|
|
105472
105504
|
}
|
|
105473
105505
|
function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
|
|
105474
|
-
|
|
105506
|
+
Debug.checkDefined(resolution.files).delete(filePath);
|
|
105475
105507
|
resolution.refCount--;
|
|
105476
105508
|
if (resolution.refCount) {
|
|
105477
105509
|
return;
|
|
105478
105510
|
}
|
|
105479
105511
|
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
105480
105512
|
if (resolved && resolved.resolvedFileName) {
|
|
105481
|
-
|
|
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);
|
|
105482
105517
|
}
|
|
105483
105518
|
const { failedLookupLocations, affectingLocations } = resolution;
|
|
105484
|
-
if (
|
|
105519
|
+
if (resolutionsWithFailedLookups.delete(resolution)) {
|
|
105485
105520
|
let removeAtRoot = false;
|
|
105486
105521
|
for (const failedLookupLocation of failedLookupLocations) {
|
|
105487
105522
|
const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
@@ -105508,7 +105543,7 @@ ${lanes.join("\n")}
|
|
|
105508
105543
|
removeDirectoryWatcher(rootPath);
|
|
105509
105544
|
}
|
|
105510
105545
|
} else if (affectingLocations == null ? void 0 : affectingLocations.length) {
|
|
105511
|
-
|
|
105546
|
+
resolutionsWithOnlyAffectingLocations.delete(resolution);
|
|
105512
105547
|
}
|
|
105513
105548
|
if (affectingLocations) {
|
|
105514
105549
|
for (const affectingLocation of affectingLocations) {
|
|
@@ -105556,15 +105591,15 @@ ${lanes.join("\n")}
|
|
|
105556
105591
|
if (!resolutions)
|
|
105557
105592
|
return false;
|
|
105558
105593
|
let invalidated = false;
|
|
105559
|
-
|
|
105594
|
+
resolutions.forEach((resolution) => {
|
|
105560
105595
|
if (resolution.isInvalidated || !canInvalidate(resolution))
|
|
105561
|
-
|
|
105596
|
+
return;
|
|
105562
105597
|
resolution.isInvalidated = invalidated = true;
|
|
105563
105598
|
for (const containingFilePath of Debug.checkDefined(resolution.files)) {
|
|
105564
105599
|
(filesWithInvalidatedResolutions != null ? filesWithInvalidatedResolutions : filesWithInvalidatedResolutions = /* @__PURE__ */ new Set()).add(containingFilePath);
|
|
105565
105600
|
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
|
|
105566
105601
|
}
|
|
105567
|
-
}
|
|
105602
|
+
});
|
|
105568
105603
|
return invalidated;
|
|
105569
105604
|
}
|
|
105570
105605
|
function invalidateResolutionOfFile(filePath) {
|
|
@@ -106129,7 +106164,6 @@ ${lanes.join("\n")}
|
|
|
106129
106164
|
getEnvironmentVariable: maybeBind(host, host.getEnvironmentVariable) || (() => ""),
|
|
106130
106165
|
createHash: maybeBind(host, host.createHash),
|
|
106131
106166
|
readDirectory: maybeBind(host, host.readDirectory),
|
|
106132
|
-
disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
|
|
106133
106167
|
storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit
|
|
106134
106168
|
};
|
|
106135
106169
|
return compilerHost;
|
|
@@ -106196,7 +106230,6 @@ ${lanes.join("\n")}
|
|
|
106196
106230
|
writeFile: (path, data, writeByteOrderMark) => system.writeFile(path, data, writeByteOrderMark),
|
|
106197
106231
|
createHash: maybeBind(system, system.createHash),
|
|
106198
106232
|
createProgram: createProgram2 || createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
106199
|
-
disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
|
|
106200
106233
|
storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
|
|
106201
106234
|
now: maybeBind(system, system.now)
|
|
106202
106235
|
};
|
|
@@ -106337,7 +106370,6 @@ ${lanes.join("\n")}
|
|
|
106337
106370
|
function createIncrementalCompilerHost(options, system = sys) {
|
|
106338
106371
|
const host = createCompilerHostWorker(options, void 0, system);
|
|
106339
106372
|
host.createHash = maybeBind(system, system.createHash);
|
|
106340
|
-
host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
|
|
106341
106373
|
host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
|
|
106342
106374
|
setGetSourceFileAsHashVersioned(host);
|
|
106343
106375
|
changeCompilerHostLikeToUseCache(host, (fileName) => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName));
|
|
@@ -129634,6 +129666,7 @@ ${lanes.join("\n")}
|
|
|
129634
129666
|
isTypeOnlyLocation,
|
|
129635
129667
|
isJsxIdentifierExpected,
|
|
129636
129668
|
isRightOfOpenTag,
|
|
129669
|
+
isRightOfDotOrQuestionDot,
|
|
129637
129670
|
importStatementCompletion,
|
|
129638
129671
|
insideJsDocTagTypeExpression,
|
|
129639
129672
|
symbolToSortTextMap,
|
|
@@ -129699,7 +129732,7 @@ ${lanes.join("\n")}
|
|
|
129699
129732
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
|
|
129700
129733
|
}
|
|
129701
129734
|
let caseBlock;
|
|
129702
|
-
if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
|
|
129735
|
+
if (preferences.includeCompletionsWithInsertText && contextToken && !isRightOfOpenTag && !isRightOfDotOrQuestionDot && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
|
|
129703
129736
|
const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
|
|
129704
129737
|
if (cases) {
|
|
129705
129738
|
entries.push(cases.entry);
|
|
@@ -131070,6 +131103,7 @@ ${lanes.join("\n")}
|
|
|
131070
131103
|
isTypeOnlyLocation,
|
|
131071
131104
|
isJsxIdentifierExpected,
|
|
131072
131105
|
isRightOfOpenTag,
|
|
131106
|
+
isRightOfDotOrQuestionDot: isRightOfDot || isRightOfQuestionDot,
|
|
131073
131107
|
importStatementCompletion,
|
|
131074
131108
|
hasUnresolvedAutoImports,
|
|
131075
131109
|
flags
|
|
@@ -138164,10 +138198,17 @@ ${lanes.join("\n")}
|
|
|
138164
138198
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
138165
138199
|
const currentDirectory = getDirectoryPath(oldFile.fileName);
|
|
138166
138200
|
const extension = extensionFromPath(oldFile.fileName);
|
|
138167
|
-
const
|
|
138168
|
-
|
|
138169
|
-
|
|
138170
|
-
|
|
138201
|
+
const newFilename = combinePaths(
|
|
138202
|
+
currentDirectory,
|
|
138203
|
+
makeUniqueFilename(
|
|
138204
|
+
inferNewFilename(usage.oldFileImportsFromNewFile, usage.movedSymbols),
|
|
138205
|
+
extension,
|
|
138206
|
+
currentDirectory,
|
|
138207
|
+
host
|
|
138208
|
+
)
|
|
138209
|
+
) + extension;
|
|
138210
|
+
changes.createNewFile(oldFile, newFilename, getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences));
|
|
138211
|
+
addNewFileToTsconfig(program, changes, oldFile.fileName, newFilename, hostGetCanonicalFileName(host));
|
|
138171
138212
|
}
|
|
138172
138213
|
function getStatementsToMove(context) {
|
|
138173
138214
|
const rangeToMove = getRangeToMove(context);
|
|
@@ -138210,7 +138251,7 @@ ${lanes.join("\n")}
|
|
|
138210
138251
|
changes.insertNodeInListAfter(cfg, last(filesProp.initializer.elements), factory.createStringLiteral(newFilePath), filesProp.initializer.elements);
|
|
138211
138252
|
}
|
|
138212
138253
|
}
|
|
138213
|
-
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program,
|
|
138254
|
+
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, host, newFilename, preferences) {
|
|
138214
138255
|
const checker = program.getTypeChecker();
|
|
138215
138256
|
const prologueDirectives = takeWhile(oldFile.statements, isPrologueDirective);
|
|
138216
138257
|
if (oldFile.externalModuleIndicator === void 0 && oldFile.commonJsModuleIndicator === void 0 && usage.oldImportsNeededByNewFile.size() === 0) {
|
|
@@ -138219,14 +138260,14 @@ ${lanes.join("\n")}
|
|
|
138219
138260
|
}
|
|
138220
138261
|
const useEsModuleSyntax = !!oldFile.externalModuleIndicator;
|
|
138221
138262
|
const quotePreference = getQuotePreference(oldFile, preferences);
|
|
138222
|
-
const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile,
|
|
138263
|
+
const importsFromNewFile = createOldFileImportsFromNewFile(oldFile, usage.oldFileImportsFromNewFile, newFilename, program, host, useEsModuleSyntax, quotePreference);
|
|
138223
138264
|
if (importsFromNewFile) {
|
|
138224
138265
|
insertImports(changes, oldFile, importsFromNewFile, true);
|
|
138225
138266
|
}
|
|
138226
138267
|
deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
|
|
138227
138268
|
deleteMovedStatements(oldFile, toMove.ranges, changes);
|
|
138228
|
-
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols,
|
|
138229
|
-
const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
|
|
138269
|
+
updateImportsInOtherFiles(changes, program, host, oldFile, usage.movedSymbols, newFilename);
|
|
138270
|
+
const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference);
|
|
138230
138271
|
const body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
|
|
138231
138272
|
if (imports.length && body.length) {
|
|
138232
138273
|
return [
|
|
@@ -138254,7 +138295,7 @@ ${lanes.join("\n")}
|
|
|
138254
138295
|
forEachImportInStatement(statement, (i) => deleteUnusedImports(oldFile, i, changes, (name) => toDelete.has(checker.getSymbolAtLocation(name))));
|
|
138255
138296
|
}
|
|
138256
138297
|
}
|
|
138257
|
-
function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols,
|
|
138298
|
+
function updateImportsInOtherFiles(changes, program, host, oldFile, movedSymbols, newFilename) {
|
|
138258
138299
|
const checker = program.getTypeChecker();
|
|
138259
138300
|
for (const sourceFile of program.getSourceFiles()) {
|
|
138260
138301
|
if (sourceFile === oldFile)
|
|
@@ -138268,13 +138309,14 @@ ${lanes.join("\n")}
|
|
|
138268
138309
|
return !!symbol && movedSymbols.has(symbol);
|
|
138269
138310
|
};
|
|
138270
138311
|
deleteUnusedImports(sourceFile, importNode, changes, shouldMove);
|
|
138271
|
-
const
|
|
138312
|
+
const pathToNewFileWithExtension = resolvePath(getDirectoryPath(oldFile.path), newFilename);
|
|
138313
|
+
const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToNewFileWithExtension, createModuleSpecifierResolutionHost(program, host));
|
|
138272
138314
|
const newImportDeclaration = filterImport(importNode, factory.createStringLiteral(newModuleSpecifier), shouldMove);
|
|
138273
138315
|
if (newImportDeclaration)
|
|
138274
138316
|
changes.insertNodeAfter(sourceFile, statement, newImportDeclaration);
|
|
138275
138317
|
const ns = getNamespaceLikeImport(importNode);
|
|
138276
138318
|
if (ns)
|
|
138277
|
-
updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols,
|
|
138319
|
+
updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleSpecifier, ns, importNode);
|
|
138278
138320
|
});
|
|
138279
138321
|
}
|
|
138280
138322
|
}
|
|
@@ -138291,8 +138333,8 @@ ${lanes.join("\n")}
|
|
|
138291
138333
|
return Debug.assertNever(node, `Unexpected node kind ${node.kind}`);
|
|
138292
138334
|
}
|
|
138293
138335
|
}
|
|
138294
|
-
function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols,
|
|
138295
|
-
const preferredNewNamespaceName = ts_codefix_exports.moduleSpecifierToValidIdentifier(
|
|
138336
|
+
function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleSpecifier, oldImportId, oldImportNode) {
|
|
138337
|
+
const preferredNewNamespaceName = ts_codefix_exports.moduleSpecifierToValidIdentifier(newModuleSpecifier, 99 /* ESNext */);
|
|
138296
138338
|
let needUniqueName = false;
|
|
138297
138339
|
const toChange = [];
|
|
138298
138340
|
ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, (ref) => {
|
|
@@ -138308,7 +138350,7 @@ ${lanes.join("\n")}
|
|
|
138308
138350
|
for (const ref of toChange) {
|
|
138309
138351
|
changes.replaceNode(sourceFile, ref, factory.createIdentifier(newNamespaceName));
|
|
138310
138352
|
}
|
|
138311
|
-
changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode,
|
|
138353
|
+
changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, preferredNewNamespaceName, newModuleSpecifier));
|
|
138312
138354
|
}
|
|
138313
138355
|
}
|
|
138314
138356
|
function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) {
|
|
@@ -138349,7 +138391,7 @@ ${lanes.join("\n")}
|
|
|
138349
138391
|
}
|
|
138350
138392
|
}
|
|
138351
138393
|
}
|
|
138352
|
-
function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports, quotePreference) {
|
|
138394
|
+
function createOldFileImportsFromNewFile(sourceFile, newFileNeedExport, newFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
|
|
138353
138395
|
let defaultImport;
|
|
138354
138396
|
const imports = [];
|
|
138355
138397
|
newFileNeedExport.forEach((symbol) => {
|
|
@@ -138359,17 +138401,18 @@ ${lanes.join("\n")}
|
|
|
138359
138401
|
imports.push(symbol.name);
|
|
138360
138402
|
}
|
|
138361
138403
|
});
|
|
138362
|
-
return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, quotePreference);
|
|
138404
|
+
return makeImportOrRequire(sourceFile, defaultImport, imports, newFileNameWithExtension, program, host, useEs6Imports, quotePreference);
|
|
138363
138405
|
}
|
|
138364
|
-
function makeImportOrRequire(defaultImport, imports,
|
|
138365
|
-
|
|
138406
|
+
function makeImportOrRequire(sourceFile, defaultImport, imports, newFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
|
|
138407
|
+
const pathToNewFile = resolvePath(getDirectoryPath(sourceFile.path), newFileNameWithExtension);
|
|
138408
|
+
const pathToNewFileWithCorrectExtension = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToNewFile, createModuleSpecifierResolutionHost(program, host));
|
|
138366
138409
|
if (useEs6Imports) {
|
|
138367
138410
|
const specifiers = imports.map((i) => factory.createImportSpecifier(false, void 0, factory.createIdentifier(i)));
|
|
138368
|
-
return makeImportIfNecessary(defaultImport, specifiers,
|
|
138411
|
+
return makeImportIfNecessary(defaultImport, specifiers, pathToNewFileWithCorrectExtension, quotePreference);
|
|
138369
138412
|
} else {
|
|
138370
138413
|
Debug.assert(!defaultImport, "No default import should exist");
|
|
138371
138414
|
const bindingElements = imports.map((i) => factory.createBindingElement(void 0, void 0, i));
|
|
138372
|
-
return bindingElements.length ? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), void 0, createRequireCall(factory.createStringLiteral(
|
|
138415
|
+
return bindingElements.length ? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), void 0, createRequireCall(factory.createStringLiteral(pathToNewFileWithCorrectExtension))) : void 0;
|
|
138373
138416
|
}
|
|
138374
138417
|
}
|
|
138375
138418
|
function makeVariableStatement(name, type, initializer, flags = 2 /* Const */) {
|
|
@@ -138466,7 +138509,7 @@ ${lanes.join("\n")}
|
|
|
138466
138509
|
break;
|
|
138467
138510
|
}
|
|
138468
138511
|
}
|
|
138469
|
-
function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) {
|
|
138512
|
+
function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, program, host, useEsModuleSyntax, quotePreference) {
|
|
138470
138513
|
const copiedOldImports = [];
|
|
138471
138514
|
for (const oldStatement of oldFile.statements) {
|
|
138472
138515
|
forEachImportInStatement(oldStatement, (i) => {
|
|
@@ -138497,19 +138540,19 @@ ${lanes.join("\n")}
|
|
|
138497
138540
|
}
|
|
138498
138541
|
}
|
|
138499
138542
|
});
|
|
138500
|
-
append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports,
|
|
138543
|
+
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
138501
138544
|
return copiedOldImports;
|
|
138502
138545
|
}
|
|
138503
|
-
function
|
|
138504
|
-
let
|
|
138546
|
+
function makeUniqueFilename(proposedFilename, extension, inDirectory, host) {
|
|
138547
|
+
let newFilename = proposedFilename;
|
|
138505
138548
|
for (let i = 1; ; i++) {
|
|
138506
|
-
const name = combinePaths(inDirectory,
|
|
138549
|
+
const name = combinePaths(inDirectory, newFilename + extension);
|
|
138507
138550
|
if (!host.fileExists(name))
|
|
138508
|
-
return
|
|
138509
|
-
|
|
138551
|
+
return newFilename;
|
|
138552
|
+
newFilename = `${proposedFilename}.${i}`;
|
|
138510
138553
|
}
|
|
138511
138554
|
}
|
|
138512
|
-
function
|
|
138555
|
+
function inferNewFilename(importsFromNewFile, movedSymbols) {
|
|
138513
138556
|
return importsFromNewFile.forEachEntry(symbolNameNoDefault) || movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile";
|
|
138514
138557
|
}
|
|
138515
138558
|
function getUsageInfo(oldFile, toMove, checker) {
|
|
@@ -138783,6 +138826,7 @@ ${lanes.join("\n")}
|
|
|
138783
138826
|
var init_moveToNewFile = __esm({
|
|
138784
138827
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
138785
138828
|
"use strict";
|
|
138829
|
+
init_moduleSpecifiers();
|
|
138786
138830
|
init_ts4();
|
|
138787
138831
|
init_ts_refactor();
|
|
138788
138832
|
refactorName4 = "Move to a new file";
|