@typescript-deploys/pr-build 5.0.0-pr-50996-2 → 5.0.0-pr-51492-2

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/tsserver.js CHANGED
@@ -253,7 +253,6 @@ var ts = (() => {
253
253
  canHaveModifiers: () => canHaveModifiers,
254
254
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
255
255
  canProduceDiagnostics: () => canProduceDiagnostics,
256
- canUsePropertyAccess: () => canUsePropertyAccess,
257
256
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
258
257
  cartesianProduct: () => cartesianProduct,
259
258
  cast: () => cast,
@@ -1929,7 +1928,6 @@ var ts = (() => {
1929
1928
  isUnparsedSource: () => isUnparsedSource,
1930
1929
  isUnparsedTextLike: () => isUnparsedTextLike,
1931
1930
  isUrl: () => isUrl,
1932
- isValidBigIntString: () => isValidBigIntString,
1933
1931
  isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
1934
1932
  isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
1935
1933
  isValueSignatureDeclaration: () => isValueSignatureDeclaration,
@@ -2061,7 +2059,6 @@ var ts = (() => {
2061
2059
  parameterIsThisKeyword: () => parameterIsThisKeyword,
2062
2060
  parameterNamePart: () => parameterNamePart,
2063
2061
  parseBaseNodeFactory: () => parseBaseNodeFactory,
2064
- parseBigInt: () => parseBigInt,
2065
2062
  parseBuildCommand: () => parseBuildCommand,
2066
2063
  parseCommandLine: () => parseCommandLine,
2067
2064
  parseCommandLineWorker: () => parseCommandLineWorker,
@@ -2080,7 +2077,6 @@ var ts = (() => {
2080
2077
  parseNodeModuleFromPath: () => parseNodeModuleFromPath,
2081
2078
  parsePackageName: () => parsePackageName,
2082
2079
  parsePseudoBigInt: () => parsePseudoBigInt,
2083
- parseValidBigInt: () => parseValidBigInt,
2084
2080
  patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
2085
2081
  pathContainsNodeModules: () => pathContainsNodeModules,
2086
2082
  pathIsAbsolute: () => pathIsAbsolute,
@@ -7274,19 +7270,19 @@ ${lanes.join("\n")}
7274
7270
  PollingWatchKind3[PollingWatchKind3["FixedChunkSize"] = 3] = "FixedChunkSize";
7275
7271
  return PollingWatchKind3;
7276
7272
  })(PollingWatchKind || {});
7277
- var ModuleKind = /* @__PURE__ */ ((ModuleKind7) => {
7278
- ModuleKind7[ModuleKind7["None"] = 0] = "None";
7279
- ModuleKind7[ModuleKind7["CommonJS"] = 1] = "CommonJS";
7280
- ModuleKind7[ModuleKind7["AMD"] = 2] = "AMD";
7281
- ModuleKind7[ModuleKind7["UMD"] = 3] = "UMD";
7282
- ModuleKind7[ModuleKind7["System"] = 4] = "System";
7283
- ModuleKind7[ModuleKind7["ES2015"] = 5] = "ES2015";
7284
- ModuleKind7[ModuleKind7["ES2020"] = 6] = "ES2020";
7285
- ModuleKind7[ModuleKind7["ES2022"] = 7] = "ES2022";
7286
- ModuleKind7[ModuleKind7["ESNext"] = 99] = "ESNext";
7287
- ModuleKind7[ModuleKind7["Node16"] = 100] = "Node16";
7288
- ModuleKind7[ModuleKind7["NodeNext"] = 199] = "NodeNext";
7289
- return ModuleKind7;
7273
+ var ModuleKind = /* @__PURE__ */ ((ModuleKind3) => {
7274
+ ModuleKind3[ModuleKind3["None"] = 0] = "None";
7275
+ ModuleKind3[ModuleKind3["CommonJS"] = 1] = "CommonJS";
7276
+ ModuleKind3[ModuleKind3["AMD"] = 2] = "AMD";
7277
+ ModuleKind3[ModuleKind3["UMD"] = 3] = "UMD";
7278
+ ModuleKind3[ModuleKind3["System"] = 4] = "System";
7279
+ ModuleKind3[ModuleKind3["ES2015"] = 5] = "ES2015";
7280
+ ModuleKind3[ModuleKind3["ES2020"] = 6] = "ES2020";
7281
+ ModuleKind3[ModuleKind3["ES2022"] = 7] = "ES2022";
7282
+ ModuleKind3[ModuleKind3["ESNext"] = 99] = "ESNext";
7283
+ ModuleKind3[ModuleKind3["Node16"] = 100] = "Node16";
7284
+ ModuleKind3[ModuleKind3["NodeNext"] = 199] = "NodeNext";
7285
+ return ModuleKind3;
7290
7286
  })(ModuleKind || {});
7291
7287
  var JsxEmit = /* @__PURE__ */ ((JsxEmit3) => {
7292
7288
  JsxEmit3[JsxEmit3["None"] = 0] = "None";
@@ -19811,32 +19807,6 @@ ${lanes.join("\n")}
19811
19807
  function pseudoBigIntToString({ negative, base10Value }) {
19812
19808
  return (negative && base10Value !== "0" ? "-" : "") + base10Value;
19813
19809
  }
19814
- function parseBigInt(text) {
19815
- if (!isValidBigIntString(text, false)) {
19816
- return void 0;
19817
- }
19818
- return parseValidBigInt(text);
19819
- }
19820
- function parseValidBigInt(text) {
19821
- const negative = text.startsWith("-");
19822
- const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
19823
- return { negative, base10Value };
19824
- }
19825
- function isValidBigIntString(s, roundTripOnly) {
19826
- if (s === "")
19827
- return false;
19828
- const scanner2 = createScanner(99 /* ESNext */, false);
19829
- let success = true;
19830
- scanner2.setOnError(() => success = false);
19831
- scanner2.setText(s + "n");
19832
- let result = scanner2.scan();
19833
- const negative = result === 40 /* MinusToken */;
19834
- if (negative) {
19835
- result = scanner2.scan();
19836
- }
19837
- const flags = scanner2.getTokenFlags();
19838
- return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
19839
- }
19840
19810
  function isValidTypeOnlyAliasUseSite(useSite) {
19841
19811
  return !!(useSite.flags & 16777216 /* Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
19842
19812
  }
@@ -20163,10 +20133,6 @@ ${lanes.join("\n")}
20163
20133
  const { isBracketed, typeExpression } = node;
20164
20134
  return isBracketed || !!typeExpression && typeExpression.type.kind === 319 /* JSDocOptionalType */;
20165
20135
  }
20166
- function canUsePropertyAccess(name, languageVersion) {
20167
- const firstChar = name.charCodeAt(0);
20168
- return firstChar === 35 /* hash */ ? name.length > 1 && isIdentifierStart(name.charCodeAt(1), languageVersion) : isIdentifierStart(firstChar, languageVersion);
20169
- }
20170
20136
 
20171
20137
  // src/compiler/factory/baseNodeFactory.ts
20172
20138
  function createBaseNodeFactory() {
@@ -42374,11 +42340,11 @@ ${lanes.join("\n")}
42374
42340
  if (specifier && modulePath.isRedirect) {
42375
42341
  return nodeModulesSpecifiers;
42376
42342
  }
42377
- if (!specifier && !modulePath.isRedirect) {
42343
+ if (!specifier) {
42378
42344
  const local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
42379
42345
  if (pathIsBareSpecifier(local)) {
42380
42346
  pathsSpecifiers = append(pathsSpecifiers, local);
42381
- } else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) {
42347
+ } else if (!modulePath.isRedirect && (!importedFileIsInNodeModules || modulePath.isInNodeModules)) {
42382
42348
  relativeSpecifiers = append(relativeSpecifiers, local);
42383
42349
  }
42384
42350
  }
@@ -42403,31 +42369,29 @@ ${lanes.join("\n")}
42403
42369
  return relativePath;
42404
42370
  }
42405
42371
  const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
42406
- const nonRelative = fromPaths === void 0 && baseUrl !== void 0 ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
42407
- if (!nonRelative) {
42372
+ const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
42373
+ if (!maybeNonRelative) {
42408
42374
  return relativePath;
42409
42375
  }
42410
- if (relativePreference === 1 /* NonRelative */) {
42411
- return nonRelative;
42376
+ if (relativePreference === 1 /* NonRelative */ && !pathIsRelative(maybeNonRelative)) {
42377
+ return maybeNonRelative;
42412
42378
  }
42413
- if (relativePreference === 3 /* ExternalNonRelative */) {
42379
+ if (relativePreference === 3 /* ExternalNonRelative */ && !pathIsRelative(maybeNonRelative)) {
42414
42380
  const projectDirectory = compilerOptions.configFilePath ? toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory());
42415
42381
  const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
42416
42382
  const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
42417
42383
  const targetIsInternal = startsWith(modulePath, projectDirectory);
42418
42384
  if (sourceIsInternal && !targetIsInternal || !sourceIsInternal && targetIsInternal) {
42419
- return nonRelative;
42385
+ return maybeNonRelative;
42420
42386
  }
42421
42387
  const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
42422
42388
  const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
42423
42389
  if (nearestSourcePackageJson !== nearestTargetPackageJson) {
42424
- return nonRelative;
42390
+ return maybeNonRelative;
42425
42391
  }
42426
42392
  return relativePath;
42427
42393
  }
42428
- if (relativePreference !== 2 /* Shortest */)
42429
- Debug.assertNever(relativePreference);
42430
- return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
42394
+ return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
42431
42395
  }
42432
42396
  function countPathComponents(path) {
42433
42397
  let count = 0;
@@ -48031,7 +47995,8 @@ ${lanes.join("\n")}
48031
47995
  if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
48032
47996
  return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
48033
47997
  }
48034
- if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
47998
+ const canUsePropertyAccess = firstChar === 35 /* hash */ ? symbolName2.length > 1 && isIdentifierStart(symbolName2.charCodeAt(1), languageVersion) : isIdentifierStart(firstChar, languageVersion);
47999
+ if (index === 0 || canUsePropertyAccess) {
48035
48000
  const identifier = setEmitFlags(factory.createIdentifier(symbolName2, typeParameterNodes), 16777216 /* NoAsciiEscaping */);
48036
48001
  identifier.symbol = symbol2;
48037
48002
  return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
@@ -60087,7 +60052,24 @@ ${lanes.join("\n")}
60087
60052
  return isFinite(n) && (!roundTripOnly || "" + n === s);
60088
60053
  }
60089
60054
  function parseBigIntLiteralType(text) {
60090
- return getBigIntLiteralType(parseValidBigInt(text));
60055
+ const negative = text.startsWith("-");
60056
+ const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
60057
+ return getBigIntLiteralType({ negative, base10Value });
60058
+ }
60059
+ function isValidBigIntString(s, roundTripOnly) {
60060
+ if (s === "")
60061
+ return false;
60062
+ const scanner2 = createScanner(99 /* ESNext */, false);
60063
+ let success = true;
60064
+ scanner2.setOnError(() => success = false);
60065
+ scanner2.setText(s + "n");
60066
+ let result = scanner2.scan();
60067
+ const negative = result === 40 /* MinusToken */;
60068
+ if (negative) {
60069
+ result = scanner2.scan();
60070
+ }
60071
+ const flags = scanner2.getTokenFlags();
60072
+ return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
60091
60073
  }
60092
60074
  function isMemberOfStringMapping(source, target) {
60093
60075
  if (target.flags & (4 /* String */ | 1 /* Any */)) {
@@ -107266,12 +107248,12 @@ ${lanes.join("\n")}
107266
107248
  const resolved = getResolutionWithResolvedFileName(resolution);
107267
107249
  trace(
107268
107250
  host,
107269
- loader === resolveModuleName2 ? (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packagetId ? 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.packagetId ? 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,
107251
+ 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,
107270
107252
  name,
107271
107253
  containingFile,
107272
107254
  getDirectoryPath(containingFile),
107273
107255
  resolved == null ? void 0 : resolved.resolvedFileName,
107274
- (resolved == null ? void 0 : resolved.packagetId) && packageIdToString(resolved.packagetId)
107256
+ (resolved == null ? void 0 : resolved.packageId) && packageIdToString(resolved.packageId)
107275
107257
  );
107276
107258
  }
107277
107259
  } else {
@@ -107296,11 +107278,11 @@ ${lanes.join("\n")}
107296
107278
  const resolved = getResolutionWithResolvedFileName(resolution);
107297
107279
  trace(
107298
107280
  host,
107299
- loader === resolveModuleName2 ? (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packagetId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packagetId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved,
107281
+ loader === resolveModuleName2 ? (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved,
107300
107282
  name,
107301
107283
  containingFile,
107302
107284
  resolved == null ? void 0 : resolved.resolvedFileName,
107303
- (resolved == null ? void 0 : resolved.packagetId) && packageIdToString(resolved.packagetId)
107285
+ (resolved == null ? void 0 : resolved.packageId) && packageIdToString(resolved.packageId)
107304
107286
  );
107305
107287
  }
107306
107288
  }
@@ -111605,7 +111587,6 @@ ${lanes.join("\n")}
111605
111587
  canHaveModifiers: () => canHaveModifiers,
111606
111588
  canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
111607
111589
  canProduceDiagnostics: () => canProduceDiagnostics,
111608
- canUsePropertyAccess: () => canUsePropertyAccess,
111609
111590
  canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
111610
111591
  cartesianProduct: () => cartesianProduct,
111611
111592
  cast: () => cast,
@@ -113281,7 +113262,6 @@ ${lanes.join("\n")}
113281
113262
  isUnparsedSource: () => isUnparsedSource,
113282
113263
  isUnparsedTextLike: () => isUnparsedTextLike,
113283
113264
  isUrl: () => isUrl,
113284
- isValidBigIntString: () => isValidBigIntString,
113285
113265
  isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
113286
113266
  isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
113287
113267
  isValueSignatureDeclaration: () => isValueSignatureDeclaration,
@@ -113413,7 +113393,6 @@ ${lanes.join("\n")}
113413
113393
  parameterIsThisKeyword: () => parameterIsThisKeyword,
113414
113394
  parameterNamePart: () => parameterNamePart,
113415
113395
  parseBaseNodeFactory: () => parseBaseNodeFactory,
113416
- parseBigInt: () => parseBigInt,
113417
113396
  parseBuildCommand: () => parseBuildCommand,
113418
113397
  parseCommandLine: () => parseCommandLine,
113419
113398
  parseCommandLineWorker: () => parseCommandLineWorker,
@@ -113432,7 +113411,6 @@ ${lanes.join("\n")}
113432
113411
  parseNodeModuleFromPath: () => parseNodeModuleFromPath,
113433
113412
  parsePackageName: () => parsePackageName,
113434
113413
  parsePseudoBigInt: () => parsePseudoBigInt,
113435
- parseValidBigInt: () => parseValidBigInt,
113436
113414
  patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
113437
113415
  pathContainsNodeModules: () => pathContainsNodeModules,
113438
113416
  pathIsAbsolute: () => pathIsAbsolute,
@@ -133145,7 +133123,6 @@ ${lanes.join("\n")}
133145
133123
  CompletionSource2["ClassMemberSnippet"] = "ClassMemberSnippet/";
133146
133124
  CompletionSource2["TypeOnlyAlias"] = "TypeOnlyAlias/";
133147
133125
  CompletionSource2["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
133148
- CompletionSource2["SwitchCases"] = "SwitchCases/";
133149
133126
  return CompletionSource2;
133150
133127
  })(CompletionSource || {});
133151
133128
  var SymbolOriginInfoKind = /* @__PURE__ */ ((SymbolOriginInfoKind2) => {
@@ -133476,13 +133453,6 @@ ${lanes.join("\n")}
133476
133453
  if (!isChecked) {
133477
133454
  getJSCompletionEntries(sourceFile, location2.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
133478
133455
  }
133479
- let caseBlock;
133480
- if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
133481
- const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
133482
- if (cases) {
133483
- entries.push(cases.entry);
133484
- }
133485
- }
133486
133456
  return {
133487
133457
  flags: completionData.flags,
133488
133458
  isGlobalCompletion: isInSnippetScope,
@@ -133496,194 +133466,6 @@ ${lanes.join("\n")}
133496
133466
  function isCheckedFile(sourceFile, compilerOptions) {
133497
133467
  return !isSourceFileJS(sourceFile) || !!isCheckJsEnabledForFile(sourceFile, compilerOptions);
133498
133468
  }
133499
- function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options, host, program, formatContext) {
133500
- const clauses = caseBlock.clauses;
133501
- const checker = program.getTypeChecker();
133502
- const switchType = checker.getTypeAtLocation(caseBlock.parent.expression);
133503
- if (switchType && switchType.isUnion() && every(switchType.types, (type) => type.isLiteral())) {
133504
- const tracker = newCaseClauseTracker(checker);
133505
- for (const clause of clauses) {
133506
- if (!isDefaultClause(clause)) {
133507
- tracker.addClause(clause);
133508
- }
133509
- }
133510
- const target = getEmitScriptTarget(options);
133511
- const quotePreference = getQuotePreference(sourceFile, preferences);
133512
- const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
133513
- const elements = [];
133514
- for (const type of switchType.types) {
133515
- if (type.flags & 1024 /* EnumLiteral */) {
133516
- Debug.assert(type.symbol, "An enum member type should have a symbol");
133517
- Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
133518
- const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
133519
- if (enumValue !== void 0) {
133520
- if (tracker.hasValue(enumValue)) {
133521
- continue;
133522
- }
133523
- tracker.addValue(enumValue);
133524
- }
133525
- const typeNode = ts_codefix_exports.typeToAutoImportableTypeNode(checker, importAdder, type, caseBlock, target);
133526
- if (!typeNode) {
133527
- return void 0;
133528
- }
133529
- const expr = typeNodeToExpression(typeNode, target, quotePreference);
133530
- if (!expr) {
133531
- return void 0;
133532
- }
133533
- elements.push(expr);
133534
- } else if (!tracker.hasValue(type.value)) {
133535
- switch (typeof type.value) {
133536
- case "object":
133537
- elements.push(factory.createBigIntLiteral(type.value));
133538
- break;
133539
- case "number":
133540
- elements.push(factory.createNumericLiteral(type.value));
133541
- break;
133542
- case "string":
133543
- elements.push(factory.createStringLiteral(type.value));
133544
- break;
133545
- }
133546
- }
133547
- }
133548
- if (elements.length === 0) {
133549
- return void 0;
133550
- }
133551
- const newClauses = map(elements, (element) => {
133552
- return factory.createCaseClause(element, []);
133553
- });
133554
- const printer = createSnippetPrinter({
133555
- removeComments: true,
133556
- module: options.module,
133557
- target: options.target,
133558
- newLine: getNewLineKind(getNewLineCharacter(options, maybeBind(host, host.getNewLine)))
133559
- });
133560
- const insertText = formatContext ? printer.printAndFormatSnippetList(
133561
- 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */,
133562
- factory.createNodeArray(newClauses),
133563
- sourceFile,
133564
- formatContext
133565
- ) : printer.printSnippetList(
133566
- 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */,
133567
- factory.createNodeArray(newClauses),
133568
- sourceFile
133569
- );
133570
- const firstClause = printer.printSnippetList(0 /* SingleLine */, factory.createNodeArray([first(newClauses)]), sourceFile);
133571
- return {
133572
- entry: {
133573
- name: `${firstClause} ...`,
133574
- kind: "" /* unknown */,
133575
- sortText: SortText.GlobalsOrKeywords,
133576
- insertText,
133577
- hasAction: importAdder.hasFixes() || void 0,
133578
- source: "SwitchCases/" /* SwitchCases */
133579
- },
133580
- importAdder
133581
- };
133582
- }
133583
- return void 0;
133584
- }
133585
- function newCaseClauseTracker(checker) {
133586
- const existingStrings = /* @__PURE__ */ new Set();
133587
- const existingNumbers = /* @__PURE__ */ new Set();
133588
- const existingBigInts = /* @__PURE__ */ new Set();
133589
- return {
133590
- addValue,
133591
- addClause,
133592
- hasValue
133593
- };
133594
- function addClause(clause) {
133595
- if (isLiteralExpression(clause.expression)) {
133596
- const expression = clause.expression;
133597
- switch (expression.kind) {
133598
- case 14 /* NoSubstitutionTemplateLiteral */:
133599
- case 10 /* StringLiteral */:
133600
- existingStrings.add(expression.text);
133601
- break;
133602
- case 8 /* NumericLiteral */:
133603
- existingNumbers.add(parseInt(expression.text));
133604
- break;
133605
- case 9 /* BigIntLiteral */:
133606
- const parsedBigInt = parseBigInt(endsWith(expression.text, "n") ? expression.text.slice(0, -1) : expression.text);
133607
- if (parsedBigInt) {
133608
- existingBigInts.add(pseudoBigIntToString(parsedBigInt));
133609
- }
133610
- break;
133611
- }
133612
- } else {
133613
- const symbol = checker.getSymbolAtLocation(clause.expression);
133614
- if (symbol && symbol.valueDeclaration && isEnumMember(symbol.valueDeclaration)) {
133615
- const enumValue = checker.getConstantValue(symbol.valueDeclaration);
133616
- if (enumValue !== void 0) {
133617
- addValue(enumValue);
133618
- }
133619
- }
133620
- }
133621
- }
133622
- function addValue(value) {
133623
- switch (typeof value) {
133624
- case "string":
133625
- existingStrings.add(value);
133626
- break;
133627
- case "number":
133628
- existingNumbers.add(value);
133629
- }
133630
- }
133631
- function hasValue(value) {
133632
- switch (typeof value) {
133633
- case "string":
133634
- return existingStrings.has(value);
133635
- case "number":
133636
- return existingNumbers.has(value);
133637
- case "object":
133638
- return existingBigInts.has(pseudoBigIntToString(value));
133639
- }
133640
- }
133641
- }
133642
- function typeNodeToExpression(typeNode, languageVersion, quotePreference) {
133643
- switch (typeNode.kind) {
133644
- case 180 /* TypeReference */:
133645
- const typeName = typeNode.typeName;
133646
- return entityNameToExpression(typeName, languageVersion, quotePreference);
133647
- case 196 /* IndexedAccessType */:
133648
- const objectExpression = typeNodeToExpression(typeNode.objectType, languageVersion, quotePreference);
133649
- const indexExpression = typeNodeToExpression(typeNode.indexType, languageVersion, quotePreference);
133650
- return objectExpression && indexExpression && factory.createElementAccessExpression(objectExpression, indexExpression);
133651
- case 198 /* LiteralType */:
133652
- const literal = typeNode.literal;
133653
- switch (literal.kind) {
133654
- case 10 /* StringLiteral */:
133655
- return factory.createStringLiteral(literal.text, quotePreference === 0 /* Single */);
133656
- case 8 /* NumericLiteral */:
133657
- return factory.createNumericLiteral(literal.text, literal.numericLiteralFlags);
133658
- }
133659
- return void 0;
133660
- case 193 /* ParenthesizedType */:
133661
- const exp = typeNodeToExpression(typeNode.type, languageVersion, quotePreference);
133662
- return exp && (isIdentifier(exp) ? exp : factory.createParenthesizedExpression(exp));
133663
- case 183 /* TypeQuery */:
133664
- return entityNameToExpression(typeNode.exprName, languageVersion, quotePreference);
133665
- case 202 /* ImportType */:
133666
- Debug.fail(`We should not get an import type after calling 'codefix.typeToAutoImportableTypeNode'.`);
133667
- }
133668
- return void 0;
133669
- }
133670
- function entityNameToExpression(entityName, languageVersion, quotePreference) {
133671
- if (isIdentifier(entityName)) {
133672
- return entityName;
133673
- }
133674
- const realName = unescapeLeadingUnderscores(entityName.right.escapedText);
133675
- if (canUsePropertyAccess(realName, languageVersion)) {
133676
- return factory.createPropertyAccessExpression(
133677
- entityNameToExpression(entityName.left, languageVersion, quotePreference),
133678
- realName
133679
- );
133680
- } else {
133681
- return factory.createElementAccessExpression(
133682
- entityNameToExpression(entityName.left, languageVersion, quotePreference),
133683
- factory.createStringLiteral(realName, quotePreference === 0 /* Single */)
133684
- );
133685
- }
133686
- }
133687
133469
  function isMemberCompletionKind(kind) {
133688
133470
  switch (kind) {
133689
133471
  case CompletionKind.ObjectPropertyDeclaration:
@@ -134342,9 +134124,6 @@ ${lanes.join("\n")}
134342
134124
  return entries;
134343
134125
  }
134344
134126
  function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) {
134345
- if (entryId.source === "SwitchCases/" /* SwitchCases */) {
134346
- return { type: "cases" };
134347
- }
134348
134127
  if (entryId.data) {
134349
134128
  const autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
134350
134129
  if (autoImport) {
@@ -134383,9 +134162,9 @@ ${lanes.join("\n")}
134383
134162
  const typeChecker = program.getTypeChecker();
134384
134163
  const compilerOptions = program.getCompilerOptions();
134385
134164
  const { name, source, data } = entryId;
134386
- const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
134387
- if (isInString(sourceFile, position, previousToken)) {
134388
- return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
134165
+ const contextToken = findPrecedingToken(position, sourceFile);
134166
+ if (isInString(sourceFile, position, contextToken)) {
134167
+ return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
134389
134168
  }
134390
134169
  const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
134391
134170
  switch (symbolCompletion.type) {
@@ -134405,40 +134184,14 @@ ${lanes.join("\n")}
134405
134184
  }
134406
134185
  }
134407
134186
  case "symbol": {
134408
- const { symbol, location: location2, contextToken: contextToken2, origin, previousToken: previousToken2 } = symbolCompletion;
134409
- const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location2, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken2, formatContext, preferences, data, source, cancellationToken);
134187
+ const { symbol, location: location2, contextToken: contextToken2, origin, previousToken } = symbolCompletion;
134188
+ const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location2, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source, cancellationToken);
134410
134189
  return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location2, cancellationToken, codeActions, sourceDisplay);
134411
134190
  }
134412
134191
  case "literal": {
134413
134192
  const { literal } = symbolCompletion;
134414
134193
  return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? 8 /* stringLiteral */ : 7 /* numericLiteral */);
134415
134194
  }
134416
- case "cases": {
134417
- const { entry, importAdder } = getExhaustiveCaseSnippets(
134418
- contextToken.parent,
134419
- sourceFile,
134420
- preferences,
134421
- program.getCompilerOptions(),
134422
- host,
134423
- program,
134424
- void 0
134425
- );
134426
- const changes = ts_textChanges_exports.ChangeTracker.with(
134427
- { host, formatContext, preferences },
134428
- importAdder.writeFixes
134429
- );
134430
- return {
134431
- name: entry.name,
134432
- kind: "" /* unknown */,
134433
- kindModifiers: "",
134434
- displayParts: [],
134435
- sourceDisplay: void 0,
134436
- codeActions: [{
134437
- changes,
134438
- description: diagnosticToString([Diagnostics.Includes_imports_of_types_referenced_by_0, name])
134439
- }]
134440
- };
134441
- }
134442
134195
  case "none":
134443
134196
  return allKeywordsCompletions().some((c) => c.name === name) ? createSimpleDetails(name, "keyword" /* keyword */, 5 /* keyword */) : void 0;
134444
134197
  default:
@@ -151906,7 +151659,7 @@ ${options.prefix}` : "\n" : options.prefix
151906
151659
  CompletionTriggerKind: () => CompletionTriggerKind2,
151907
151660
  IndentStyle: () => IndentStyle2,
151908
151661
  JsxEmit: () => JsxEmit2,
151909
- ModuleKind: () => ModuleKind5,
151662
+ ModuleKind: () => ModuleKind2,
151910
151663
  ModuleResolutionKind: () => ModuleResolutionKind2,
151911
151664
  NewLineKind: () => NewLineKind2,
151912
151665
  OrganizeImportsMode: () => OrganizeImportsMode2,
@@ -152083,17 +151836,17 @@ ${options.prefix}` : "\n" : options.prefix
152083
151836
  JsxEmit3["React"] = "React";
152084
151837
  return JsxEmit3;
152085
151838
  })(JsxEmit2 || {});
152086
- var ModuleKind5 = /* @__PURE__ */ ((ModuleKind7) => {
152087
- ModuleKind7["None"] = "None";
152088
- ModuleKind7["CommonJS"] = "CommonJS";
152089
- ModuleKind7["AMD"] = "AMD";
152090
- ModuleKind7["UMD"] = "UMD";
152091
- ModuleKind7["System"] = "System";
152092
- ModuleKind7["ES6"] = "ES6";
152093
- ModuleKind7["ES2015"] = "ES2015";
152094
- ModuleKind7["ESNext"] = "ESNext";
152095
- return ModuleKind7;
152096
- })(ModuleKind5 || {});
151839
+ var ModuleKind2 = /* @__PURE__ */ ((ModuleKind3) => {
151840
+ ModuleKind3["None"] = "None";
151841
+ ModuleKind3["CommonJS"] = "CommonJS";
151842
+ ModuleKind3["AMD"] = "AMD";
151843
+ ModuleKind3["UMD"] = "UMD";
151844
+ ModuleKind3["System"] = "System";
151845
+ ModuleKind3["ES6"] = "ES6";
151846
+ ModuleKind3["ES2015"] = "ES2015";
151847
+ ModuleKind3["ESNext"] = "ESNext";
151848
+ return ModuleKind3;
151849
+ })(ModuleKind2 || {});
152097
151850
  var ModuleResolutionKind2 = /* @__PURE__ */ ((ModuleResolutionKind3) => {
152098
151851
  ModuleResolutionKind3["Classic"] = "Classic";
152099
151852
  ModuleResolutionKind3["Node"] = "Node";