typescript 5.0.0-dev.20221201 → 5.0.0-dev.20221203

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/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.20221201`;
45
+ version = `${versionMajorMinor}.0-dev.20221203`;
46
46
  Comparison = /* @__PURE__ */ ((Comparison3) => {
47
47
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
48
48
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -17095,6 +17095,32 @@ ${lanes.join("\n")}
17095
17095
  function pseudoBigIntToString({ negative, base10Value }) {
17096
17096
  return (negative && base10Value !== "0" ? "-" : "") + base10Value;
17097
17097
  }
17098
+ function parseBigInt(text) {
17099
+ if (!isValidBigIntString(text, false)) {
17100
+ return void 0;
17101
+ }
17102
+ return parseValidBigInt(text);
17103
+ }
17104
+ function parseValidBigInt(text) {
17105
+ const negative = text.startsWith("-");
17106
+ const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
17107
+ return { negative, base10Value };
17108
+ }
17109
+ function isValidBigIntString(s, roundTripOnly) {
17110
+ if (s === "")
17111
+ return false;
17112
+ const scanner2 = createScanner(99 /* ESNext */, false);
17113
+ let success = true;
17114
+ scanner2.setOnError(() => success = false);
17115
+ scanner2.setText(s + "n");
17116
+ let result = scanner2.scan();
17117
+ const negative = result === 40 /* MinusToken */;
17118
+ if (negative) {
17119
+ result = scanner2.scan();
17120
+ }
17121
+ const flags = scanner2.getTokenFlags();
17122
+ return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
17123
+ }
17098
17124
  function isValidTypeOnlyAliasUseSite(useSite) {
17099
17125
  return !!(useSite.flags & 16777216 /* Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
17100
17126
  }
@@ -17421,6 +17447,17 @@ ${lanes.join("\n")}
17421
17447
  const { isBracketed, typeExpression } = node;
17422
17448
  return isBracketed || !!typeExpression && typeExpression.type.kind === 319 /* JSDocOptionalType */;
17423
17449
  }
17450
+ function canUsePropertyAccess(name, languageVersion) {
17451
+ if (name.length === 0) {
17452
+ return false;
17453
+ }
17454
+ const firstChar = name.charCodeAt(0);
17455
+ return firstChar === 35 /* hash */ ? name.length > 1 && isIdentifierStart(name.charCodeAt(1), languageVersion) : isIdentifierStart(firstChar, languageVersion);
17456
+ }
17457
+ function hasTabstop(node) {
17458
+ var _a2;
17459
+ return ((_a2 = getSnippetElement(node)) == null ? void 0 : _a2.kind) === 0 /* TabStop */;
17460
+ }
17424
17461
  var resolvingEmptyArray, externalHelpersModuleNameText, defaultMaximumTruncationLength, noTruncationMaximumTruncationLength, stringWriter, GetLiteralTextFlags, fullTripleSlashReferencePathRegEx, fullTripleSlashReferenceTypeReferenceDirectiveRegEx, fullTripleSlashAMDReferencePathRegEx, defaultLibReferenceRegEx, AssignmentKind, FunctionFlags, Associativity, OperatorPrecedence, templateSubstitutionRegExp, doubleQuoteEscapedCharsRegExp, singleQuoteEscapedCharsRegExp, backtickQuoteEscapedCharsRegExp, escapedCharsMap, nonAsciiCharacters, jsxDoubleQuoteEscapedCharsRegExp, jsxSingleQuoteEscapedCharsRegExp, jsxEscapedCharsMap, indentStrings, base64Digits, carriageReturnLineFeed, lineFeed, AccessKind, objectAllocator, localizedDiagnosticMessages, reservedCharacterPattern, wildcardCharCodes, commonPackageFolders, implicitExcludePathRegexPattern, filesMatcher, directoriesMatcher, excludeMatcher, wildcardMatchers, supportedTSExtensions, supportedTSExtensionsFlat, supportedTSExtensionsWithJson, supportedTSExtensionsForExtractExtension, supportedJSExtensions, supportedJSExtensionsFlat, allSupportedExtensions, allSupportedExtensionsWithJson, supportedDeclarationExtensions, supportedTSImplementationExtensions, extensionsToRemove, emptyFileSystemEntries;
17425
17462
  var init_utilities = __esm({
17426
17463
  "src/compiler/utilities.ts"() {
@@ -35262,41 +35299,86 @@ ${lanes.join("\n")}
35262
35299
  }
35263
35300
  return result;
35264
35301
  }
35265
- function createCacheWithRedirects(options) {
35266
- let ownMap = /* @__PURE__ */ new Map();
35302
+ function compilerOptionValueToString(value) {
35303
+ var _a2;
35304
+ if (value === null || typeof value !== "object") {
35305
+ return "" + value;
35306
+ }
35307
+ if (isArray(value)) {
35308
+ return `[${(_a2 = value.map((e) => compilerOptionValueToString(e))) == null ? void 0 : _a2.join(",")}]`;
35309
+ }
35310
+ let str = "{";
35311
+ for (const key in value) {
35312
+ if (hasProperty(value, key)) {
35313
+ str += `${key}: ${compilerOptionValueToString(value[key])}`;
35314
+ }
35315
+ }
35316
+ return str + "}";
35317
+ }
35318
+ function getKeyForCompilerOptions(options, affectingOptionDeclarations) {
35319
+ return affectingOptionDeclarations.map((option) => compilerOptionValueToString(getCompilerOptionValue(options, option))).join("|") + (options.pathsBasePath ? `|${options.pathsBasePath}` : void 0);
35320
+ }
35321
+ function createCacheWithRedirects(ownOptions) {
35267
35322
  const redirectsMap = /* @__PURE__ */ new Map();
35323
+ const optionsToRedirectsKey = /* @__PURE__ */ new Map();
35324
+ const redirectsKeyToMap = /* @__PURE__ */ new Map();
35325
+ let ownMap = /* @__PURE__ */ new Map();
35326
+ if (ownOptions)
35327
+ redirectsMap.set(ownOptions, ownMap);
35268
35328
  return {
35269
- getOwnMap,
35270
- redirectsMap,
35271
35329
  getOrCreateMapOfCacheRedirects,
35272
- clear: clear2,
35273
- setOwnOptions,
35274
- setOwnMap
35330
+ update,
35331
+ clear: clear2
35275
35332
  };
35276
- function getOwnMap() {
35277
- return ownMap;
35278
- }
35279
- function setOwnOptions(newOptions) {
35280
- options = newOptions;
35281
- }
35282
- function setOwnMap(newOwnMap) {
35283
- ownMap = newOwnMap;
35284
- }
35285
35333
  function getOrCreateMapOfCacheRedirects(redirectedReference) {
35286
- if (!redirectedReference) {
35287
- return ownMap;
35334
+ return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options) : ownMap;
35335
+ }
35336
+ function update(newOptions) {
35337
+ if (ownOptions !== newOptions) {
35338
+ if (ownOptions)
35339
+ ownMap = getOrCreateMap(newOptions);
35340
+ else
35341
+ redirectsMap.set(newOptions, ownMap);
35342
+ ownOptions = newOptions;
35288
35343
  }
35289
- const path = redirectedReference.sourceFile.path;
35290
- let redirects = redirectsMap.get(path);
35291
- if (!redirects) {
35292
- redirects = !options || optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? /* @__PURE__ */ new Map() : ownMap;
35293
- redirectsMap.set(path, redirects);
35344
+ }
35345
+ function getOrCreateMap(redirectOptions) {
35346
+ let result = redirectsMap.get(redirectOptions);
35347
+ if (result)
35348
+ return result;
35349
+ const key = getRedirectsCacheKey(redirectOptions);
35350
+ result = redirectsKeyToMap.get(key);
35351
+ if (!result) {
35352
+ if (ownOptions) {
35353
+ const ownKey = getRedirectsCacheKey(ownOptions);
35354
+ if (ownKey === key)
35355
+ result = ownMap;
35356
+ else if (!redirectsKeyToMap.has(ownKey))
35357
+ redirectsKeyToMap.set(ownKey, ownMap);
35358
+ }
35359
+ redirectsKeyToMap.set(key, result != null ? result : result = /* @__PURE__ */ new Map());
35294
35360
  }
35295
- return redirects;
35361
+ redirectsMap.set(redirectOptions, result);
35362
+ return result;
35296
35363
  }
35297
35364
  function clear2() {
35365
+ const ownKey = ownOptions && optionsToRedirectsKey.get(ownOptions);
35298
35366
  ownMap.clear();
35299
35367
  redirectsMap.clear();
35368
+ optionsToRedirectsKey.clear();
35369
+ redirectsKeyToMap.clear();
35370
+ if (ownOptions) {
35371
+ if (ownKey)
35372
+ optionsToRedirectsKey.set(ownOptions, ownKey);
35373
+ redirectsMap.set(ownOptions, ownMap);
35374
+ }
35375
+ }
35376
+ function getRedirectsCacheKey(options) {
35377
+ let result = optionsToRedirectsKey.get(options);
35378
+ if (!result) {
35379
+ optionsToRedirectsKey.set(options, result = getKeyForCompilerOptions(options, moduleResolutionOptionDeclarations));
35380
+ }
35381
+ return result;
35300
35382
  }
35301
35383
  }
35302
35384
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
@@ -35328,27 +35410,6 @@ ${lanes.join("\n")}
35328
35410
  }
35329
35411
  return result;
35330
35412
  }
35331
- function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35332
- if (!options.configFile)
35333
- return;
35334
- if (directoryToModuleNameMap.redirectsMap.size === 0) {
35335
- Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
35336
- Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
35337
- Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
35338
- directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
35339
- moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
35340
- } else {
35341
- Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
35342
- const ref = {
35343
- sourceFile: options.configFile,
35344
- commandLine: { options }
35345
- };
35346
- directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
35347
- moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
35348
- }
35349
- directoryToModuleNameMap.setOwnOptions(options);
35350
- moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
35351
- }
35352
35413
  function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
35353
35414
  return {
35354
35415
  getOrCreateCacheForDirectory,
@@ -35359,13 +35420,16 @@ ${lanes.join("\n")}
35359
35420
  directoryToModuleNameMap.clear();
35360
35421
  }
35361
35422
  function update(options) {
35362
- updateRedirectsMap(options, directoryToModuleNameMap);
35423
+ directoryToModuleNameMap.update(options);
35363
35424
  }
35364
35425
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
35365
35426
  const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
35366
35427
  return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
35367
35428
  }
35368
35429
  }
35430
+ function createModeAwareCacheKey(specifier, mode) {
35431
+ return mode === void 0 ? specifier : `${mode}|${specifier}`;
35432
+ }
35369
35433
  function createModeAwareCache() {
35370
35434
  const underlying = /* @__PURE__ */ new Map();
35371
35435
  const memoizedReverseKeys = /* @__PURE__ */ new Map();
@@ -35396,7 +35460,7 @@ ${lanes.join("\n")}
35396
35460
  };
35397
35461
  return cache;
35398
35462
  function getUnderlyingCacheKey(specifier, mode) {
35399
- const result = mode === void 0 ? specifier : `${mode}|${specifier}`;
35463
+ const result = createModeAwareCacheKey(specifier, mode);
35400
35464
  memoizedReverseKeys.set(result, [specifier, mode]);
35401
35465
  return result;
35402
35466
  }
@@ -35416,9 +35480,10 @@ ${lanes.join("\n")}
35416
35480
  }
35417
35481
  return map2;
35418
35482
  }
35419
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35420
- const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35421
- moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
35483
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35484
+ const directoryToModuleNameMap = createCacheWithRedirects(options);
35485
+ const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35486
+ const moduleNameToDirectoryMap = createCacheWithRedirects(options);
35422
35487
  const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35423
35488
  return {
35424
35489
  ...packageJsonInfoCache,
@@ -35438,11 +35503,12 @@ ${lanes.join("\n")}
35438
35503
  moduleNameToDirectoryMap.clear();
35439
35504
  }
35440
35505
  function update(options2) {
35441
- updateRedirectsMap(options2, directoryToModuleNameMap, moduleNameToDirectoryMap);
35506
+ directoryToModuleNameMap.update(options2);
35507
+ moduleNameToDirectoryMap.update(options2);
35442
35508
  }
35443
35509
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
35444
35510
  Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
35445
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === void 0 ? nonRelativeModuleName : `${mode}|${nonRelativeModuleName}`, createPerModuleNameCache);
35511
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
35446
35512
  }
35447
35513
  function createPerModuleNameCache() {
35448
35514
  const directoryPathMap = /* @__PURE__ */ new Map();
@@ -35490,8 +35556,9 @@ ${lanes.join("\n")}
35490
35556
  }
35491
35557
  }
35492
35558
  }
35493
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
35494
- const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35559
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35560
+ const directoryToModuleNameMap = createCacheWithRedirects(options);
35561
+ const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35495
35562
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35496
35563
  return {
35497
35564
  ...packageJsonInfoCache,
@@ -45171,7 +45238,7 @@ ${lanes.join("\n")}
45171
45238
  }
45172
45239
  const contextFile = getSourceFileOfNode(getOriginalNode(context.enclosingDeclaration));
45173
45240
  const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
45174
- const cacheKey = getSpecifierCacheKey(contextFile.path, resolutionMode);
45241
+ const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
45175
45242
  const links = getSymbolLinks(symbol);
45176
45243
  let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
45177
45244
  if (!specifier) {
@@ -45194,9 +45261,6 @@ ${lanes.join("\n")}
45194
45261
  links.specifierCache.set(cacheKey, specifier);
45195
45262
  }
45196
45263
  return specifier;
45197
- function getSpecifierCacheKey(path, mode) {
45198
- return mode === void 0 ? path : `${mode}|${path}`;
45199
- }
45200
45264
  }
45201
45265
  function symbolToEntityNameNode(symbol) {
45202
45266
  const identifier = factory.createIdentifier(unescapeLeadingUnderscores(symbol.escapedName));
@@ -45410,8 +45474,7 @@ ${lanes.join("\n")}
45410
45474
  if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
45411
45475
  return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
45412
45476
  }
45413
- const canUsePropertyAccess = firstChar === 35 /* hash */ ? symbolName2.length > 1 && isIdentifierStart(symbolName2.charCodeAt(1), languageVersion) : isIdentifierStart(firstChar, languageVersion);
45414
- if (index === 0 || canUsePropertyAccess) {
45477
+ if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
45415
45478
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2, typeParameterNodes), 33554432 /* NoAsciiEscaping */);
45416
45479
  identifier.symbol = symbol2;
45417
45480
  return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
@@ -57483,24 +57546,7 @@ ${lanes.join("\n")}
57483
57546
  return isFinite(n) && (!roundTripOnly || "" + n === s);
57484
57547
  }
57485
57548
  function parseBigIntLiteralType(text) {
57486
- const negative = text.startsWith("-");
57487
- const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
57488
- return getBigIntLiteralType({ negative, base10Value });
57489
- }
57490
- function isValidBigIntString(s, roundTripOnly) {
57491
- if (s === "")
57492
- return false;
57493
- const scanner2 = createScanner(99 /* ESNext */, false);
57494
- let success = true;
57495
- scanner2.setOnError(() => success = false);
57496
- scanner2.setText(s + "n");
57497
- let result = scanner2.scan();
57498
- const negative = result === 40 /* MinusToken */;
57499
- if (negative) {
57500
- result = scanner2.scan();
57501
- }
57502
- const flags = scanner2.getTokenFlags();
57503
- return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
57549
+ return getBigIntLiteralType(parseValidBigInt(text));
57504
57550
  }
57505
57551
  function isMemberOfStringMapping(source, target) {
57506
57552
  if (target.flags & (4 /* String */ | 1 /* Any */)) {
@@ -64972,11 +65018,11 @@ ${lanes.join("\n")}
64972
65018
  }
64973
65019
  function checkSatisfiesExpression(node) {
64974
65020
  checkSourceElement(node.type);
65021
+ const exprType = checkExpression(node.expression);
64975
65022
  const targetType = getTypeFromTypeNode(node.type);
64976
65023
  if (isErrorType(targetType)) {
64977
65024
  return targetType;
64978
65025
  }
64979
- const exprType = checkExpression(node.expression);
64980
65026
  checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
64981
65027
  return exprType;
64982
65028
  }
@@ -100158,16 +100204,15 @@ ${lanes.join("\n")}
100158
100204
  return [];
100159
100205
  }
100160
100206
  const resolutions = [];
100161
- const cache = /* @__PURE__ */ new Map();
100207
+ const cache = createModeAwareCache();
100162
100208
  for (const name of names) {
100163
100209
  let result;
100164
100210
  const mode = getModeForFileReference(name, containingFileMode);
100165
100211
  const strName = getResolutionName(name);
100166
- const cacheKey = mode !== void 0 ? `${mode}|${strName}` : strName;
100167
- if (cache.has(cacheKey)) {
100168
- result = cache.get(cacheKey);
100212
+ if (cache.has(strName, mode)) {
100213
+ result = cache.get(strName, mode);
100169
100214
  } else {
100170
- cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
100215
+ cache.set(strName, mode, result = loader(strName, containingFile, redirectedReference, mode));
100171
100216
  }
100172
100217
  resolutions.push(result);
100173
100218
  }
@@ -100243,18 +100288,17 @@ ${lanes.join("\n")}
100243
100288
  return [];
100244
100289
  }
100245
100290
  const resolutions = [];
100246
- const cache = /* @__PURE__ */ new Map();
100291
+ const cache = createModeAwareCache();
100247
100292
  let i = 0;
100248
100293
  for (const entry of resolutionInfo ? resolutionInfo.names : names) {
100249
100294
  let result;
100250
100295
  const mode = !isString(entry) ? getModeForUsageLocation(containingFile, entry) : getModeForResolutionAtIndex(containingFile, i);
100251
100296
  i++;
100252
100297
  const name = isString(entry) ? entry : entry.text;
100253
- const cacheKey = mode !== void 0 ? `${mode}|${name}` : name;
100254
- if (cache.has(cacheKey)) {
100255
- result = cache.get(cacheKey);
100298
+ if (cache.has(name, mode)) {
100299
+ result = cache.get(name, mode);
100256
100300
  } else {
100257
- cache.set(cacheKey, result = loader(name, mode, containingFileName, redirectedReference));
100301
+ cache.set(name, mode, result = loader(name, mode, containingFileName, redirectedReference));
100258
100302
  }
100259
100303
  resolutions.push(result);
100260
100304
  }
@@ -104830,23 +104874,17 @@ ${lanes.join("\n")}
104830
104874
  const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory());
104831
104875
  const cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
104832
104876
  const resolvedModuleNames = /* @__PURE__ */ new Map();
104833
- const perDirectoryResolvedModuleNames = createCacheWithRedirects();
104834
- const nonRelativeModuleNameCache = createCacheWithRedirects();
104835
104877
  const moduleResolutionCache = createModuleResolutionCache(
104836
104878
  getCurrentDirectory(),
104837
104879
  resolutionHost.getCanonicalFileName,
104838
- void 0,
104839
- perDirectoryResolvedModuleNames,
104840
- nonRelativeModuleNameCache
104880
+ resolutionHost.getCompilationSettings()
104841
104881
  );
104842
104882
  const resolvedTypeReferenceDirectives = /* @__PURE__ */ new Map();
104843
- const perDirectoryResolvedTypeReferenceDirectives = createCacheWithRedirects();
104844
104883
  const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(
104845
104884
  getCurrentDirectory(),
104846
104885
  resolutionHost.getCanonicalFileName,
104847
- void 0,
104848
- moduleResolutionCache.getPackageJsonInfoCache(),
104849
- perDirectoryResolvedTypeReferenceDirectives
104886
+ resolutionHost.getCompilationSettings(),
104887
+ moduleResolutionCache.getPackageJsonInfoCache()
104850
104888
  );
104851
104889
  const failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
104852
104890
  const customFailedLookupPaths = /* @__PURE__ */ new Map();
@@ -104907,6 +104945,8 @@ ${lanes.join("\n")}
104907
104945
  affectingPathChecksForFile = void 0;
104908
104946
  moduleResolutionCache.clear();
104909
104947
  typeReferenceDirectiveResolutionCache.clear();
104948
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
104949
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
104910
104950
  impliedFormatPackageJsons.clear();
104911
104951
  hasChangedAutomaticTypeDirectiveNames = false;
104912
104952
  }
@@ -105011,8 +105051,7 @@ ${lanes.join("\n")}
105011
105051
  names,
105012
105052
  containingFile,
105013
105053
  redirectedReference,
105014
- cache,
105015
- perDirectoryCacheWithRedirects,
105054
+ perFileCache,
105016
105055
  loader,
105017
105056
  getResolutionWithResolvedFileName,
105018
105057
  shouldRetryResolution,
@@ -105022,16 +105061,9 @@ ${lanes.join("\n")}
105022
105061
  containingSourceFile,
105023
105062
  containingSourceFileMode
105024
105063
  }) {
105025
- var _a2, _b, _c, _d;
105064
+ var _a2, _b, _c;
105026
105065
  const path = resolutionHost.toPath(containingFile);
105027
- const resolutionsInFile = cache.get(path) || cache.set(path, createModeAwareCache()).get(path);
105028
- const dirPath = getDirectoryPath(path);
105029
- const perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
105030
- let perDirectoryResolution = perDirectoryCache.get(dirPath);
105031
- if (!perDirectoryResolution) {
105032
- perDirectoryResolution = createModeAwareCache();
105033
- perDirectoryCache.set(dirPath, perDirectoryResolution);
105034
- }
105066
+ const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
105035
105067
  const resolvedModules = [];
105036
105068
  const compilerOptions = resolutionHost.getCompilationSettings();
105037
105069
  const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
@@ -105047,28 +105079,9 @@ ${lanes.join("\n")}
105047
105079
  let resolution = resolutionsInFile.get(name, mode);
105048
105080
  if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
105049
105081
  const existingResolution = resolution;
105050
- const resolutionInDirectory = perDirectoryResolution.get(name, mode);
105051
- if (resolutionInDirectory) {
105052
- resolution = resolutionInDirectory;
105053
- const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
105054
- if (isTraceEnabled(compilerOptions, host)) {
105055
- const resolved = getResolutionWithResolvedFileName(resolution);
105056
- trace(
105057
- host,
105058
- loader === resolveModuleName2 ? (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved,
105059
- name,
105060
- containingFile,
105061
- getDirectoryPath(containingFile),
105062
- resolved == null ? void 0 : resolved.resolvedFileName,
105063
- (resolved == null ? void 0 : resolved.packageId) && packageIdToString(resolved.packageId)
105064
- );
105065
- }
105066
- } else {
105067
- resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
105068
- perDirectoryResolution.set(name, mode, resolution);
105069
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
105070
- resolutionHost.onDiscoveredSymlink();
105071
- }
105082
+ resolution = loader(name, containingFile, compilerOptions, ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
105083
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
105084
+ resolutionHost.onDiscoveredSymlink();
105072
105085
  }
105073
105086
  resolutionsInFile.set(name, mode, resolution);
105074
105087
  watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
@@ -105080,7 +105093,7 @@ ${lanes.join("\n")}
105080
105093
  logChanges = false;
105081
105094
  }
105082
105095
  } else {
105083
- const host = ((_c = resolutionHost.getCompilerHost) == null ? void 0 : _c.call(resolutionHost)) || resolutionHost;
105096
+ const host = ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost;
105084
105097
  if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
105085
105098
  const resolved = getResolutionWithResolvedFileName(resolution);
105086
105099
  trace(
@@ -105098,7 +105111,7 @@ ${lanes.join("\n")}
105098
105111
  resolvedModules.push(getResolutionWithResolvedFileName(resolution));
105099
105112
  }
105100
105113
  if (resolutionInfo && (loader === resolveTypeReferenceDirective2 || containingSourceFile)) {
105101
- (_d = resolutionInfo.reusedNames) == null ? void 0 : _d.forEach((entry) => seenNamesInFile.set(
105114
+ (_c = resolutionInfo.reusedNames) == null ? void 0 : _c.forEach((entry) => seenNamesInFile.set(
105102
105115
  getResolutionName(entry),
105103
105116
  !isString(entry) && isStringLiteralLike(entry) ? getModeForUsageLocation(containingSourceFile, entry) : getModeForFileReference(entry, containingSourceFileMode),
105104
105117
  true
@@ -105137,8 +105150,7 @@ ${lanes.join("\n")}
105137
105150
  names: typeDirectiveNames,
105138
105151
  containingFile,
105139
105152
  redirectedReference,
105140
- cache: resolvedTypeReferenceDirectives,
105141
- perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
105153
+ perFileCache: resolvedTypeReferenceDirectives,
105142
105154
  loader: resolveTypeReferenceDirective2,
105143
105155
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective2,
105144
105156
  shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
@@ -105151,8 +105163,7 @@ ${lanes.join("\n")}
105151
105163
  names: moduleNames,
105152
105164
  containingFile,
105153
105165
  redirectedReference,
105154
- cache: resolvedModuleNames,
105155
- perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
105166
+ perFileCache: resolvedModuleNames,
105156
105167
  loader: resolveModuleName2,
105157
105168
  getResolutionWithResolvedFileName: getResolvedModule2,
105158
105169
  shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
@@ -113920,24 +113931,8 @@ ${lanes.join("\n")}
113920
113931
  getKeyForCompilationSettings
113921
113932
  };
113922
113933
  }
113923
- function compilerOptionValueToString(value) {
113924
- var _a2;
113925
- if (value === null || typeof value !== "object") {
113926
- return "" + value;
113927
- }
113928
- if (isArray(value)) {
113929
- return `[${(_a2 = map(value, (e) => compilerOptionValueToString(e))) == null ? void 0 : _a2.join(",")}]`;
113930
- }
113931
- let str = "{";
113932
- for (const key in value) {
113933
- if (hasProperty(value, key)) {
113934
- str += `${key}: ${compilerOptionValueToString(value[key])}`;
113935
- }
113936
- }
113937
- return str + "}";
113938
- }
113939
113934
  function getKeyForCompilationSettings(settings) {
113940
- return sourceFileAffectingCompilerOptions.map((option) => compilerOptionValueToString(getCompilerOptionValue(settings, option))).join("|") + (settings.pathsBasePath ? `|${settings.pathsBasePath}` : void 0);
113935
+ return getKeyForCompilerOptions(settings, sourceFileAffectingCompilerOptions);
113941
113936
  }
113942
113937
  function getDocumentRegistryBucketKeyWithMode(key, mode) {
113943
113938
  return mode ? `${key}|${mode}` : key;
@@ -116135,6 +116130,9 @@ ${lanes.join("\n")}
116135
116130
  const textPos = scanner.getTextPos();
116136
116131
  if (textPos <= end) {
116137
116132
  if (token === 79 /* Identifier */) {
116133
+ if (hasTabstop(parent2)) {
116134
+ continue;
116135
+ }
116138
116136
  Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent2.kind)} to have an Identifier in its trivia`);
116139
116137
  }
116140
116138
  nodes.push(createNode(token, pos, textPos, parent2));
@@ -129576,6 +129574,13 @@ ${lanes.join("\n")}
129576
129574
  if (!isChecked) {
129577
129575
  getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
129578
129576
  }
129577
+ let caseBlock;
129578
+ if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
129579
+ const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
129580
+ if (cases) {
129581
+ entries.push(cases.entry);
129582
+ }
129583
+ }
129579
129584
  return {
129580
129585
  flags: completionData.flags,
129581
129586
  isGlobalCompletion: isInSnippetScope,
@@ -129589,6 +129594,187 @@ ${lanes.join("\n")}
129589
129594
  function isCheckedFile(sourceFile, compilerOptions) {
129590
129595
  return !isSourceFileJS(sourceFile) || !!isCheckJsEnabledForFile(sourceFile, compilerOptions);
129591
129596
  }
129597
+ function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options, host, program, formatContext) {
129598
+ const clauses = caseBlock.clauses;
129599
+ const checker = program.getTypeChecker();
129600
+ const switchType = checker.getTypeAtLocation(caseBlock.parent.expression);
129601
+ if (switchType && switchType.isUnion() && every(switchType.types, (type) => type.isLiteral())) {
129602
+ const tracker = newCaseClauseTracker(checker, clauses);
129603
+ const target = getEmitScriptTarget(options);
129604
+ const quotePreference = getQuotePreference(sourceFile, preferences);
129605
+ const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
129606
+ const elements = [];
129607
+ for (const type of switchType.types) {
129608
+ if (type.flags & 1024 /* EnumLiteral */) {
129609
+ Debug.assert(type.symbol, "An enum member type should have a symbol");
129610
+ Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
129611
+ const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
129612
+ if (enumValue !== void 0) {
129613
+ if (tracker.hasValue(enumValue)) {
129614
+ continue;
129615
+ }
129616
+ tracker.addValue(enumValue);
129617
+ }
129618
+ const typeNode = ts_codefix_exports.typeToAutoImportableTypeNode(checker, importAdder, type, caseBlock, target);
129619
+ if (!typeNode) {
129620
+ return void 0;
129621
+ }
129622
+ const expr = typeNodeToExpression(typeNode, target, quotePreference);
129623
+ if (!expr) {
129624
+ return void 0;
129625
+ }
129626
+ elements.push(expr);
129627
+ } else if (!tracker.hasValue(type.value)) {
129628
+ switch (typeof type.value) {
129629
+ case "object":
129630
+ elements.push(factory.createBigIntLiteral(type.value));
129631
+ break;
129632
+ case "number":
129633
+ elements.push(factory.createNumericLiteral(type.value));
129634
+ break;
129635
+ case "string":
129636
+ elements.push(factory.createStringLiteral(type.value));
129637
+ break;
129638
+ }
129639
+ }
129640
+ }
129641
+ if (elements.length === 0) {
129642
+ return void 0;
129643
+ }
129644
+ const newClauses = map(elements, (element) => factory.createCaseClause(element, []));
129645
+ const newLineChar = getNewLineCharacter(options, maybeBind(host, host.getNewLine));
129646
+ const printer = createSnippetPrinter({
129647
+ removeComments: true,
129648
+ module: options.module,
129649
+ target: options.target,
129650
+ newLine: getNewLineKind(newLineChar)
129651
+ });
129652
+ const printNode = formatContext ? (node) => printer.printAndFormatNode(4 /* Unspecified */, node, sourceFile, formatContext) : (node) => printer.printNode(4 /* Unspecified */, node, sourceFile);
129653
+ const insertText = map(newClauses, (clause, i) => {
129654
+ if (preferences.includeCompletionsWithSnippetText) {
129655
+ return `${printNode(clause)}$${i + 1}`;
129656
+ }
129657
+ return `${printNode(clause)}`;
129658
+ }).join(newLineChar);
129659
+ const firstClause = printer.printNode(4 /* Unspecified */, newClauses[0], sourceFile);
129660
+ return {
129661
+ entry: {
129662
+ name: `${firstClause} ...`,
129663
+ kind: "" /* unknown */,
129664
+ sortText: SortText.GlobalsOrKeywords,
129665
+ insertText,
129666
+ hasAction: importAdder.hasFixes() || void 0,
129667
+ source: "SwitchCases/" /* SwitchCases */,
129668
+ isSnippet: preferences.includeCompletionsWithSnippetText ? true : void 0
129669
+ },
129670
+ importAdder
129671
+ };
129672
+ }
129673
+ return void 0;
129674
+ }
129675
+ function newCaseClauseTracker(checker, clauses) {
129676
+ const existingStrings = /* @__PURE__ */ new Set();
129677
+ const existingNumbers = /* @__PURE__ */ new Set();
129678
+ const existingBigInts = /* @__PURE__ */ new Set();
129679
+ for (const clause of clauses) {
129680
+ if (!isDefaultClause(clause)) {
129681
+ if (isLiteralExpression(clause.expression)) {
129682
+ const expression = clause.expression;
129683
+ switch (expression.kind) {
129684
+ case 14 /* NoSubstitutionTemplateLiteral */:
129685
+ case 10 /* StringLiteral */:
129686
+ existingStrings.add(expression.text);
129687
+ break;
129688
+ case 8 /* NumericLiteral */:
129689
+ existingNumbers.add(parseInt(expression.text));
129690
+ break;
129691
+ case 9 /* BigIntLiteral */:
129692
+ const parsedBigInt = parseBigInt(endsWith(expression.text, "n") ? expression.text.slice(0, -1) : expression.text);
129693
+ if (parsedBigInt) {
129694
+ existingBigInts.add(pseudoBigIntToString(parsedBigInt));
129695
+ }
129696
+ break;
129697
+ }
129698
+ } else {
129699
+ const symbol = checker.getSymbolAtLocation(clause.expression);
129700
+ if (symbol && symbol.valueDeclaration && isEnumMember(symbol.valueDeclaration)) {
129701
+ const enumValue = checker.getConstantValue(symbol.valueDeclaration);
129702
+ if (enumValue !== void 0) {
129703
+ addValue(enumValue);
129704
+ }
129705
+ }
129706
+ }
129707
+ }
129708
+ }
129709
+ return {
129710
+ addValue,
129711
+ hasValue
129712
+ };
129713
+ function addValue(value) {
129714
+ switch (typeof value) {
129715
+ case "string":
129716
+ existingStrings.add(value);
129717
+ break;
129718
+ case "number":
129719
+ existingNumbers.add(value);
129720
+ }
129721
+ }
129722
+ function hasValue(value) {
129723
+ switch (typeof value) {
129724
+ case "string":
129725
+ return existingStrings.has(value);
129726
+ case "number":
129727
+ return existingNumbers.has(value);
129728
+ case "object":
129729
+ return existingBigInts.has(pseudoBigIntToString(value));
129730
+ }
129731
+ }
129732
+ }
129733
+ function typeNodeToExpression(typeNode, languageVersion, quotePreference) {
129734
+ switch (typeNode.kind) {
129735
+ case 180 /* TypeReference */:
129736
+ const typeName = typeNode.typeName;
129737
+ return entityNameToExpression(typeName, languageVersion, quotePreference);
129738
+ case 196 /* IndexedAccessType */:
129739
+ const objectExpression = typeNodeToExpression(typeNode.objectType, languageVersion, quotePreference);
129740
+ const indexExpression = typeNodeToExpression(typeNode.indexType, languageVersion, quotePreference);
129741
+ return objectExpression && indexExpression && factory.createElementAccessExpression(objectExpression, indexExpression);
129742
+ case 198 /* LiteralType */:
129743
+ const literal = typeNode.literal;
129744
+ switch (literal.kind) {
129745
+ case 10 /* StringLiteral */:
129746
+ return factory.createStringLiteral(literal.text, quotePreference === 0 /* Single */);
129747
+ case 8 /* NumericLiteral */:
129748
+ return factory.createNumericLiteral(literal.text, literal.numericLiteralFlags);
129749
+ }
129750
+ return void 0;
129751
+ case 193 /* ParenthesizedType */:
129752
+ const exp = typeNodeToExpression(typeNode.type, languageVersion, quotePreference);
129753
+ return exp && (isIdentifier(exp) ? exp : factory.createParenthesizedExpression(exp));
129754
+ case 183 /* TypeQuery */:
129755
+ return entityNameToExpression(typeNode.exprName, languageVersion, quotePreference);
129756
+ case 202 /* ImportType */:
129757
+ Debug.fail(`We should not get an import type after calling 'codefix.typeToAutoImportableTypeNode'.`);
129758
+ }
129759
+ return void 0;
129760
+ }
129761
+ function entityNameToExpression(entityName, languageVersion, quotePreference) {
129762
+ if (isIdentifier(entityName)) {
129763
+ return entityName;
129764
+ }
129765
+ const unescapedName = unescapeLeadingUnderscores(entityName.right.escapedText);
129766
+ if (canUsePropertyAccess(unescapedName, languageVersion)) {
129767
+ return factory.createPropertyAccessExpression(
129768
+ entityNameToExpression(entityName.left, languageVersion, quotePreference),
129769
+ unescapedName
129770
+ );
129771
+ } else {
129772
+ return factory.createElementAccessExpression(
129773
+ entityNameToExpression(entityName.left, languageVersion, quotePreference),
129774
+ factory.createStringLiteral(unescapedName, quotePreference === 0 /* Single */)
129775
+ );
129776
+ }
129777
+ }
129592
129778
  function isMemberCompletionKind(kind) {
129593
129779
  switch (kind) {
129594
129780
  case CompletionKind.ObjectPropertyDeclaration:
@@ -129995,7 +130181,9 @@ ${lanes.join("\n")}
129995
130181
  };
129996
130182
  return {
129997
130183
  printSnippetList,
129998
- printAndFormatSnippetList
130184
+ printAndFormatSnippetList,
130185
+ printNode,
130186
+ printAndFormatNode
129999
130187
  };
130000
130188
  function escapingWrite(s, write) {
130001
130189
  const escaped = escapeSnippetText(s);
@@ -130044,6 +130232,40 @@ ${lanes.join("\n")}
130044
130232
  const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
130045
130233
  return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
130046
130234
  }
130235
+ function printNode(hint, node, sourceFile) {
130236
+ const unescaped = printUnescapedNode(hint, node, sourceFile);
130237
+ return escapes ? ts_textChanges_exports.applyChanges(unescaped, escapes) : unescaped;
130238
+ }
130239
+ function printUnescapedNode(hint, node, sourceFile) {
130240
+ escapes = void 0;
130241
+ writer.clear();
130242
+ printer.writeNode(hint, node, sourceFile, writer);
130243
+ return writer.getText();
130244
+ }
130245
+ function printAndFormatNode(hint, node, sourceFile, formatContext) {
130246
+ const syntheticFile = {
130247
+ text: printUnescapedNode(
130248
+ hint,
130249
+ node,
130250
+ sourceFile
130251
+ ),
130252
+ getLineAndCharacterOfPosition(pos) {
130253
+ return getLineAndCharacterOfPosition(this, pos);
130254
+ }
130255
+ };
130256
+ const formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
130257
+ const nodeWithPos = ts_textChanges_exports.assignPositionsToNode(node);
130258
+ const changes = ts_formatting_exports.formatNodeGivenIndentation(
130259
+ nodeWithPos,
130260
+ syntheticFile,
130261
+ sourceFile.languageVariant,
130262
+ 0,
130263
+ 0,
130264
+ { ...formatContext, options: formatOptions }
130265
+ );
130266
+ const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
130267
+ return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
130268
+ }
130047
130269
  }
130048
130270
  function originToCompletionEntryData(origin) {
130049
130271
  const ambientModuleName = origin.fileName ? void 0 : stripQuotes(origin.moduleSymbol.name);
@@ -130247,6 +130469,9 @@ ${lanes.join("\n")}
130247
130469
  return entries;
130248
130470
  }
130249
130471
  function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) {
130472
+ if (entryId.source === "SwitchCases/" /* SwitchCases */) {
130473
+ return { type: "cases" };
130474
+ }
130250
130475
  if (entryId.data) {
130251
130476
  const autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
130252
130477
  if (autoImport) {
@@ -130285,9 +130510,9 @@ ${lanes.join("\n")}
130285
130510
  const typeChecker = program.getTypeChecker();
130286
130511
  const compilerOptions = program.getCompilerOptions();
130287
130512
  const { name, source, data } = entryId;
130288
- const contextToken = findPrecedingToken(position, sourceFile);
130289
- if (isInString(sourceFile, position, contextToken)) {
130290
- return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
130513
+ const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
130514
+ if (isInString(sourceFile, position, previousToken)) {
130515
+ return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
130291
130516
  }
130292
130517
  const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
130293
130518
  switch (symbolCompletion.type) {
@@ -130307,14 +130532,49 @@ ${lanes.join("\n")}
130307
130532
  }
130308
130533
  }
130309
130534
  case "symbol": {
130310
- const { symbol, location, contextToken: contextToken2, origin, previousToken } = symbolCompletion;
130311
- const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken);
130535
+ const { symbol, location, contextToken: contextToken2, origin, previousToken: previousToken2 } = symbolCompletion;
130536
+ const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken2, formatContext, preferences, data, source, cancellationToken);
130312
130537
  return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay);
130313
130538
  }
130314
130539
  case "literal": {
130315
130540
  const { literal } = symbolCompletion;
130316
130541
  return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? 8 /* stringLiteral */ : 7 /* numericLiteral */);
130317
130542
  }
130543
+ case "cases": {
130544
+ const { entry, importAdder } = getExhaustiveCaseSnippets(
130545
+ contextToken.parent,
130546
+ sourceFile,
130547
+ preferences,
130548
+ program.getCompilerOptions(),
130549
+ host,
130550
+ program,
130551
+ void 0
130552
+ );
130553
+ if (importAdder.hasFixes()) {
130554
+ const changes = ts_textChanges_exports.ChangeTracker.with(
130555
+ { host, formatContext, preferences },
130556
+ importAdder.writeFixes
130557
+ );
130558
+ return {
130559
+ name: entry.name,
130560
+ kind: "" /* unknown */,
130561
+ kindModifiers: "",
130562
+ displayParts: [],
130563
+ sourceDisplay: void 0,
130564
+ codeActions: [{
130565
+ changes,
130566
+ description: diagnosticToString([Diagnostics.Includes_imports_of_types_referenced_by_0, name])
130567
+ }]
130568
+ };
130569
+ }
130570
+ return {
130571
+ name: entry.name,
130572
+ kind: "" /* unknown */,
130573
+ kindModifiers: "",
130574
+ displayParts: [],
130575
+ sourceDisplay: void 0
130576
+ };
130577
+ }
130318
130578
  case "none":
130319
130579
  return allKeywordsCompletions().some((c) => c.name === name) ? createSimpleDetails(name, "keyword" /* keyword */, 5 /* keyword */) : void 0;
130320
130580
  default:
@@ -132201,6 +132461,7 @@ ${lanes.join("\n")}
132201
132461
  CompletionSource2["ClassMemberSnippet"] = "ClassMemberSnippet/";
132202
132462
  CompletionSource2["TypeOnlyAlias"] = "TypeOnlyAlias/";
132203
132463
  CompletionSource2["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
132464
+ CompletionSource2["SwitchCases"] = "SwitchCases/";
132204
132465
  return CompletionSource2;
132205
132466
  })(CompletionSource || {});
132206
132467
  SymbolOriginInfoKind = /* @__PURE__ */ ((SymbolOriginInfoKind2) => {
@@ -137515,12 +137776,14 @@ ${lanes.join("\n")}
137515
137776
  if (!selection || !isTypeNode(selection))
137516
137777
  return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
137517
137778
  const checker = context.program.getTypeChecker();
137518
- const firstStatement = Debug.checkDefined(findAncestor(selection, isStatement), "Should find a statement");
137519
- const typeParameters = collectTypeParameters(checker, selection, firstStatement, file);
137779
+ const enclosingNode = getEnclosingNode(selection, isJS);
137780
+ if (enclosingNode === void 0)
137781
+ return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
137782
+ const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file);
137520
137783
  if (!typeParameters)
137521
137784
  return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
137522
137785
  const typeElements = flattenTypeLiteralNodeReference(checker, selection);
137523
- return { isJS, selection, firstStatement, typeParameters, typeElements };
137786
+ return { isJS, selection, enclosingNode, typeParameters, typeElements };
137524
137787
  }
137525
137788
  function flattenTypeLiteralNodeReference(checker, node) {
137526
137789
  if (!node)
@@ -137546,7 +137809,7 @@ ${lanes.join("\n")}
137546
137809
  function rangeContainsSkipTrivia(r1, node, file) {
137547
137810
  return rangeContainsStartEnd(r1, skipTrivia(file.text, node.pos), node.end);
137548
137811
  }
137549
- function collectTypeParameters(checker, selection, statement, file) {
137812
+ function collectTypeParameters(checker, selection, enclosingNode, file) {
137550
137813
  const result = [];
137551
137814
  return visitor(selection) ? void 0 : result;
137552
137815
  function visitor(node) {
@@ -137559,7 +137822,7 @@ ${lanes.join("\n")}
137559
137822
  if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
137560
137823
  return true;
137561
137824
  }
137562
- if (rangeContainsSkipTrivia(statement, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
137825
+ if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
137563
137826
  pushIfUnique(result, decl);
137564
137827
  break;
137565
137828
  }
@@ -137579,7 +137842,7 @@ ${lanes.join("\n")}
137579
137842
  } else if (isTypeQueryNode(node)) {
137580
137843
  if (isIdentifier(node.exprName)) {
137581
137844
  const symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, false);
137582
- if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) {
137845
+ if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) {
137583
137846
  return true;
137584
137847
  }
137585
137848
  } else {
@@ -137595,19 +137858,19 @@ ${lanes.join("\n")}
137595
137858
  }
137596
137859
  }
137597
137860
  function doTypeAliasChange(changes, file, name, info) {
137598
- const { firstStatement, selection, typeParameters } = info;
137861
+ const { enclosingNode, selection, typeParameters } = info;
137599
137862
  const newTypeNode = factory.createTypeAliasDeclaration(
137600
137863
  void 0,
137601
137864
  name,
137602
137865
  typeParameters.map((id) => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, void 0)),
137603
137866
  selection
137604
137867
  );
137605
- changes.insertNodeBefore(file, firstStatement, ignoreSourceNewlines(newTypeNode), true);
137868
+ changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
137606
137869
  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 });
137607
137870
  }
137608
137871
  function doInterfaceChange(changes, file, name, info) {
137609
137872
  var _a2;
137610
- const { firstStatement, selection, typeParameters, typeElements } = info;
137873
+ const { enclosingNode, selection, typeParameters, typeElements } = info;
137611
137874
  const newTypeNode = factory.createInterfaceDeclaration(
137612
137875
  void 0,
137613
137876
  name,
@@ -137616,11 +137879,11 @@ ${lanes.join("\n")}
137616
137879
  typeElements
137617
137880
  );
137618
137881
  setTextRange(newTypeNode, (_a2 = typeElements[0]) == null ? void 0 : _a2.parent);
137619
- changes.insertNodeBefore(file, firstStatement, ignoreSourceNewlines(newTypeNode), true);
137882
+ changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
137620
137883
  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 });
137621
137884
  }
137622
- function doTypedefChange(changes, file, name, info) {
137623
- const { firstStatement, selection, typeParameters } = info;
137885
+ function doTypedefChange(changes, program, file, name, info) {
137886
+ const { enclosingNode, selection, typeParameters } = info;
137624
137887
  setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
137625
137888
  const node = factory.createJSDocTypedefTag(
137626
137889
  factory.createIdentifier("typedef"),
@@ -137638,9 +137901,21 @@ ${lanes.join("\n")}
137638
137901
  );
137639
137902
  templates.push(template);
137640
137903
  });
137641
- changes.insertNodeBefore(file, firstStatement, factory.createJSDocComment(void 0, factory.createNodeArray(concatenate(templates, [node]))), true);
137904
+ const jsDoc = factory.createJSDocComment(void 0, factory.createNodeArray(concatenate(templates, [node])));
137905
+ if (isJSDoc(enclosingNode)) {
137906
+ const pos = enclosingNode.getStart(file);
137907
+ const newLineCharacter = getNewLineCharacter(program.getCompilerOptions());
137908
+ changes.insertNodeAt(file, enclosingNode.getStart(file), jsDoc, {
137909
+ suffix: newLineCharacter + newLineCharacter + file.text.slice(getPrecedingNonSpaceCharacterPosition(file.text, pos - 1), pos)
137910
+ });
137911
+ } else {
137912
+ changes.insertNodeBefore(file, enclosingNode, jsDoc, true);
137913
+ }
137642
137914
  changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(id.name, void 0))));
137643
137915
  }
137916
+ function getEnclosingNode(node, isJS) {
137917
+ return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0);
137918
+ }
137644
137919
  var refactorName3, extractToTypeAliasAction, extractToInterfaceAction, extractToTypeDefAction;
137645
137920
  var init_extractType = __esm({
137646
137921
  "src/services/refactors/extractType.ts"() {
@@ -137694,7 +137969,7 @@ ${lanes.join("\n")}
137694
137969
  return emptyArray;
137695
137970
  },
137696
137971
  getEditsForAction: function getRefactorEditsToExtractType(context, actionName2) {
137697
- const { file } = context;
137972
+ const { file, program } = context;
137698
137973
  const info = getRangeToExtract(context);
137699
137974
  Debug.assert(info && !isRefactorErrorInfo(info), "Expected to find a range to extract");
137700
137975
  const name = getUniqueName("NewType", file);
@@ -137705,7 +137980,7 @@ ${lanes.join("\n")}
137705
137980
  return doTypeAliasChange(changes, file, name, info);
137706
137981
  case extractToTypeDefAction.name:
137707
137982
  Debug.assert(info.isJS, "Invalid actionName/JS combo");
137708
- return doTypedefChange(changes, file, name, info);
137983
+ return doTypedefChange(changes, program, file, name, info);
137709
137984
  case extractToInterfaceAction.name:
137710
137985
  Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo");
137711
137986
  return doInterfaceChange(changes, file, name, info);
@@ -148474,6 +148749,7 @@ ${options.prefix}` : "\n" : options.prefix
148474
148749
  canHaveModifiers: () => canHaveModifiers,
148475
148750
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
148476
148751
  canProduceDiagnostics: () => canProduceDiagnostics,
148752
+ canUsePropertyAccess: () => canUsePropertyAccess,
148477
148753
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
148478
148754
  cartesianProduct: () => cartesianProduct,
148479
148755
  cast: () => cast,
@@ -148750,6 +149026,7 @@ ${options.prefix}` : "\n" : options.prefix
148750
149026
  createMethod: () => createMethod,
148751
149027
  createMethodSignature: () => createMethodSignature,
148752
149028
  createModeAwareCache: () => createModeAwareCache,
149029
+ createModeAwareCacheKey: () => createModeAwareCacheKey,
148753
149030
  createModifier: () => createModifier,
148754
149031
  createModifiersFromModifierFlags: () => createModifiersFromModifierFlags,
148755
149032
  createModuleBlock: () => createModuleBlock,
@@ -149229,6 +149506,7 @@ ${options.prefix}` : "\n" : options.prefix
149229
149506
  getJSXImplicitImportBase: () => getJSXImplicitImportBase,
149230
149507
  getJSXRuntimeImport: () => getJSXRuntimeImport,
149231
149508
  getJSXTransformEnabled: () => getJSXTransformEnabled,
149509
+ getKeyForCompilerOptions: () => getKeyForCompilerOptions,
149232
149510
  getLanguageVariant: () => getLanguageVariant,
149233
149511
  getLastChild: () => getLastChild,
149234
149512
  getLeadingCommentRanges: () => getLeadingCommentRanges,
@@ -149500,6 +149778,7 @@ ${options.prefix}` : "\n" : options.prefix
149500
149778
  hasSyntacticModifier: () => hasSyntacticModifier,
149501
149779
  hasSyntacticModifiers: () => hasSyntacticModifiers,
149502
149780
  hasTSFileExtension: () => hasTSFileExtension,
149781
+ hasTabstop: () => hasTabstop,
149503
149782
  hasTrailingDirectorySeparator: () => hasTrailingDirectorySeparator,
149504
149783
  hasType: () => hasType,
149505
149784
  hasTypeArguments: () => hasTypeArguments,
@@ -150149,6 +150428,7 @@ ${options.prefix}` : "\n" : options.prefix
150149
150428
  isUnparsedSource: () => isUnparsedSource,
150150
150429
  isUnparsedTextLike: () => isUnparsedTextLike,
150151
150430
  isUrl: () => isUrl,
150431
+ isValidBigIntString: () => isValidBigIntString,
150152
150432
  isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
150153
150433
  isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
150154
150434
  isValueSignatureDeclaration: () => isValueSignatureDeclaration,
@@ -150280,6 +150560,7 @@ ${options.prefix}` : "\n" : options.prefix
150280
150560
  parameterIsThisKeyword: () => parameterIsThisKeyword,
150281
150561
  parameterNamePart: () => parameterNamePart,
150282
150562
  parseBaseNodeFactory: () => parseBaseNodeFactory,
150563
+ parseBigInt: () => parseBigInt,
150283
150564
  parseBuildCommand: () => parseBuildCommand,
150284
150565
  parseCommandLine: () => parseCommandLine,
150285
150566
  parseCommandLineWorker: () => parseCommandLineWorker,
@@ -150298,6 +150579,7 @@ ${options.prefix}` : "\n" : options.prefix
150298
150579
  parseNodeModuleFromPath: () => parseNodeModuleFromPath,
150299
150580
  parsePackageName: () => parsePackageName,
150300
150581
  parsePseudoBigInt: () => parsePseudoBigInt,
150582
+ parseValidBigInt: () => parseValidBigInt,
150301
150583
  patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
150302
150584
  pathContainsNodeModules: () => pathContainsNodeModules,
150303
150585
  pathIsAbsolute: () => pathIsAbsolute,