typescript 5.3.0-dev.20231030 → 5.3.0-dev.20231101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.3";
21
- var version = `${versionMajorMinor}.0-dev.20231030`;
21
+ var version = `${versionMajorMinor}.0-dev.20231101`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -30689,7 +30689,8 @@ var Parser;
30689
30689
  parseExpected(21 /* OpenParenToken */);
30690
30690
  let initializer;
30691
30691
  if (token() !== 27 /* SemicolonToken */) {
30692
- if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf)) {
30692
+ if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || // this one is meant to allow of
30693
+ token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine)) {
30693
30694
  initializer = parseVariableDeclarationList(
30694
30695
  /*inForStatementInitializer*/
30695
30696
  true
@@ -31010,12 +31011,6 @@ var Parser;
31010
31011
  function isUsingDeclaration() {
31011
31012
  return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine);
31012
31013
  }
31013
- function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf() {
31014
- return nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(
31015
- /*disallowOf*/
31016
- true
31017
- );
31018
- }
31019
31014
  function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(disallowOf) {
31020
31015
  if (nextToken() === 160 /* UsingKeyword */) {
31021
31016
  return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf);
@@ -37200,8 +37195,7 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
37200
37195
  if (resolutionMode === 99 /* ESNext */ && (3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) {
37201
37196
  features |= 32 /* EsmMode */;
37202
37197
  }
37203
- const useImportCondition = resolutionMode === 99 /* ESNext */ || (resolutionMode !== void 0 ? false : void 0);
37204
- const conditions = features & 8 /* Exports */ ? getConditions(options, useImportCondition) : [];
37198
+ const conditions = features & 8 /* Exports */ ? getConditions(options, resolutionMode) : [];
37205
37199
  const diagnostics = [];
37206
37200
  const moduleResolutionState = {
37207
37201
  compilerOptions: options,
@@ -37369,16 +37363,16 @@ function getNodeResolutionFeatures(options) {
37369
37363
  }
37370
37364
  return features;
37371
37365
  }
37372
- function getConditions(options, esmMode) {
37366
+ function getConditions(options, resolutionMode) {
37373
37367
  const moduleResolution = getEmitModuleResolutionKind(options);
37374
- if (esmMode === void 0) {
37368
+ if (resolutionMode === void 0) {
37375
37369
  if (moduleResolution === 100 /* Bundler */) {
37376
- esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */);
37370
+ resolutionMode = 99 /* ESNext */;
37377
37371
  } else if (moduleResolution === 2 /* Node10 */) {
37378
37372
  return [];
37379
37373
  }
37380
37374
  }
37381
- const conditions = esmMode ? ["import"] : ["require"];
37375
+ const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"];
37382
37376
  if (!options.noDtsResolution) {
37383
37377
  conditions.push("types");
37384
37378
  }
@@ -37802,13 +37796,13 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
37802
37796
  result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
37803
37797
  break;
37804
37798
  case 2 /* Node10 */:
37805
- result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
37799
+ result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
37806
37800
  break;
37807
37801
  case 1 /* Classic */:
37808
37802
  result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
37809
37803
  break;
37810
37804
  case 100 /* Bundler */:
37811
- result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
37805
+ result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
37812
37806
  break;
37813
37807
  default:
37814
37808
  return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
@@ -38073,7 +38067,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
38073
38067
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
38074
38068
  conditions ?? (conditions = getConditions(
38075
38069
  compilerOptions,
38076
- moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */)
38070
+ moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */
38077
38071
  ));
38078
38072
  const diagnostics = [];
38079
38073
  const state = {
@@ -42920,7 +42914,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
42920
42914
  if (getResolvePackageJsonExports(options)) {
42921
42915
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
42922
42916
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
42923
- const conditions = getConditions(options, importMode === 99 /* ESNext */);
42917
+ const conditions = getConditions(options, importMode);
42924
42918
  const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
42925
42919
  if (fromExports) {
42926
42920
  const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
@@ -77749,7 +77743,7 @@ function createTypeChecker(host) {
77749
77743
  }
77750
77744
  forEach(node.name.elements, checkSourceElement);
77751
77745
  }
77752
- if (isParameter(node) && node.initializer && nodeIsMissing(getContainingFunction(node).body)) {
77746
+ if (node.initializer && isParameterDeclaration(node) && nodeIsMissing(getContainingFunction(node).body)) {
77753
77747
  error(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
77754
77748
  return;
77755
77749
  }
package/lib/tsserver.js CHANGED
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
2328
2328
 
2329
2329
  // src/compiler/corePublic.ts
2330
2330
  var versionMajorMinor = "5.3";
2331
- var version = `${versionMajorMinor}.0-dev.20231030`;
2331
+ var version = `${versionMajorMinor}.0-dev.20231101`;
2332
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -35093,7 +35093,8 @@ var Parser;
35093
35093
  parseExpected(21 /* OpenParenToken */);
35094
35094
  let initializer;
35095
35095
  if (token() !== 27 /* SemicolonToken */) {
35096
- if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf)) {
35096
+ if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || // this one is meant to allow of
35097
+ token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine)) {
35097
35098
  initializer = parseVariableDeclarationList(
35098
35099
  /*inForStatementInitializer*/
35099
35100
  true
@@ -35414,12 +35415,6 @@ var Parser;
35414
35415
  function isUsingDeclaration() {
35415
35416
  return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine);
35416
35417
  }
35417
- function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf() {
35418
- return nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(
35419
- /*disallowOf*/
35420
- true
35421
- );
35422
- }
35423
35418
  function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(disallowOf) {
35424
35419
  if (nextToken() === 160 /* UsingKeyword */) {
35425
35420
  return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf);
@@ -41689,8 +41684,7 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
41689
41684
  if (resolutionMode === 99 /* ESNext */ && (3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) {
41690
41685
  features |= 32 /* EsmMode */;
41691
41686
  }
41692
- const useImportCondition = resolutionMode === 99 /* ESNext */ || (resolutionMode !== void 0 ? false : void 0);
41693
- const conditions = features & 8 /* Exports */ ? getConditions(options, useImportCondition) : [];
41687
+ const conditions = features & 8 /* Exports */ ? getConditions(options, resolutionMode) : [];
41694
41688
  const diagnostics = [];
41695
41689
  const moduleResolutionState = {
41696
41690
  compilerOptions: options,
@@ -41858,16 +41852,16 @@ function getNodeResolutionFeatures(options) {
41858
41852
  }
41859
41853
  return features;
41860
41854
  }
41861
- function getConditions(options, esmMode) {
41855
+ function getConditions(options, resolutionMode) {
41862
41856
  const moduleResolution = getEmitModuleResolutionKind(options);
41863
- if (esmMode === void 0) {
41857
+ if (resolutionMode === void 0) {
41864
41858
  if (moduleResolution === 100 /* Bundler */) {
41865
- esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */);
41859
+ resolutionMode = 99 /* ESNext */;
41866
41860
  } else if (moduleResolution === 2 /* Node10 */) {
41867
41861
  return [];
41868
41862
  }
41869
41863
  }
41870
- const conditions = esmMode ? ["import"] : ["require"];
41864
+ const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"];
41871
41865
  if (!options.noDtsResolution) {
41872
41866
  conditions.push("types");
41873
41867
  }
@@ -42316,13 +42310,13 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
42316
42310
  result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
42317
42311
  break;
42318
42312
  case 2 /* Node10 */:
42319
- result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
42313
+ result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
42320
42314
  break;
42321
42315
  case 1 /* Classic */:
42322
42316
  result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
42323
42317
  break;
42324
42318
  case 100 /* Bundler */:
42325
- result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
42319
+ result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
42326
42320
  break;
42327
42321
  default:
42328
42322
  return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
@@ -42600,7 +42594,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
42600
42594
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
42601
42595
  conditions ?? (conditions = getConditions(
42602
42596
  compilerOptions,
42603
- moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */)
42597
+ moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */
42604
42598
  ));
42605
42599
  const diagnostics = [];
42606
42600
  const state = {
@@ -42911,15 +42905,7 @@ function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache
42911
42905
  entrypoints = append(entrypoints, mainResolution == null ? void 0 : mainResolution.path);
42912
42906
  if (features & 8 /* Exports */ && packageJsonInfo.contents.packageJsonContent.exports) {
42913
42907
  const conditionSets = deduplicate(
42914
- [getConditions(
42915
- options,
42916
- /*esmMode*/
42917
- true
42918
- ), getConditions(
42919
- options,
42920
- /*esmMode*/
42921
- false
42922
- )],
42908
+ [getConditions(options, 99 /* ESNext */), getConditions(options, 1 /* CommonJS */)],
42923
42909
  arrayIsEqualTo
42924
42910
  );
42925
42911
  for (const conditions of conditionSets) {
@@ -47632,7 +47618,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
47632
47618
  if (getResolvePackageJsonExports(options)) {
47633
47619
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
47634
47620
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
47635
- const conditions = getConditions(options, importMode === 99 /* ESNext */);
47621
+ const conditions = getConditions(options, importMode);
47636
47622
  const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
47637
47623
  if (fromExports) {
47638
47624
  const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
@@ -82461,7 +82447,7 @@ function createTypeChecker(host) {
82461
82447
  }
82462
82448
  forEach(node.name.elements, checkSourceElement);
82463
82449
  }
82464
- if (isParameter(node) && node.initializer && nodeIsMissing(getContainingFunction(node).body)) {
82450
+ if (node.initializer && isParameterDeclaration(node) && nodeIsMissing(getContainingFunction(node).body)) {
82465
82451
  error2(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
82466
82452
  return;
82467
82453
  }
@@ -139449,14 +139435,13 @@ function error(notApplicableReason) {
139449
139435
  }
139450
139436
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
139451
139437
  const checker = program.getTypeChecker();
139452
- const usage = getUsageInfo(oldFile, toMove.all, checker);
139453
139438
  if (!host.fileExists(targetFile)) {
139454
- changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
139439
+ changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, getUsageInfo(oldFile, toMove.all, checker), changes, toMove, program, host, preferences));
139455
139440
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
139456
139441
  } else {
139457
139442
  const targetSourceFile = Debug.checkDefined(program.getSourceFile(targetFile));
139458
139443
  const importAdder = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host);
139459
- getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, usage, changes, toMove, program, host, preferences, importAdder);
139444
+ getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, getExistingImports(targetSourceFile, checker)), changes, toMove, program, host, preferences, importAdder);
139460
139445
  }
139461
139446
  }
139462
139447
  function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdder) {
@@ -140122,7 +140107,7 @@ function isPureImport(node) {
140122
140107
  return false;
140123
140108
  }
140124
140109
  }
140125
- function getUsageInfo(oldFile, toMove, checker) {
140110
+ function getUsageInfo(oldFile, toMove, checker, existingTargetImports = /* @__PURE__ */ new Set()) {
140126
140111
  const movedSymbols = /* @__PURE__ */ new Set();
140127
140112
  const oldImportsNeededByTargetFile = /* @__PURE__ */ new Map();
140128
140113
  const targetFileImportsFromOldFile = /* @__PURE__ */ new Set();
@@ -140136,10 +140121,16 @@ function getUsageInfo(oldFile, toMove, checker) {
140136
140121
  movedSymbols.add(Debug.checkDefined(isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here"));
140137
140122
  });
140138
140123
  }
140124
+ const unusedImportsFromOldFile = /* @__PURE__ */ new Set();
140139
140125
  for (const statement of toMove) {
140140
140126
  forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
140141
- if (!symbol.declarations)
140127
+ if (!symbol.declarations) {
140128
+ return;
140129
+ }
140130
+ if (existingTargetImports.has(skipAlias(symbol, checker))) {
140131
+ unusedImportsFromOldFile.add(symbol);
140142
140132
  return;
140133
+ }
140143
140134
  for (const decl of symbol.declarations) {
140144
140135
  if (isInImport(decl)) {
140145
140136
  const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol);
@@ -140150,7 +140141,9 @@ function getUsageInfo(oldFile, toMove, checker) {
140150
140141
  }
140151
140142
  });
140152
140143
  }
140153
- const unusedImportsFromOldFile = new Set(oldImportsNeededByTargetFile.keys());
140144
+ for (const unusedImport of oldImportsNeededByTargetFile.keys()) {
140145
+ unusedImportsFromOldFile.add(unusedImport);
140146
+ }
140154
140147
  const oldFileImportsFromTargetFile = /* @__PURE__ */ new Set();
140155
140148
  for (const statement of oldFile.statements) {
140156
140149
  if (contains(toMove, statement))
@@ -140336,6 +140329,29 @@ function getOverloadRangeToMove(sourceFile, statement) {
140336
140329
  }
140337
140330
  return void 0;
140338
140331
  }
140332
+ function getExistingImports(sourceFile, checker) {
140333
+ const imports = /* @__PURE__ */ new Set();
140334
+ for (const moduleSpecifier of sourceFile.imports) {
140335
+ const declaration = importFromModuleSpecifier(moduleSpecifier);
140336
+ if (isImportDeclaration(declaration) && declaration.importClause && declaration.importClause.namedBindings && isNamedImports(declaration.importClause.namedBindings)) {
140337
+ for (const e of declaration.importClause.namedBindings.elements) {
140338
+ const symbol = checker.getSymbolAtLocation(e.propertyName || e.name);
140339
+ if (symbol) {
140340
+ imports.add(skipAlias(symbol, checker));
140341
+ }
140342
+ }
140343
+ }
140344
+ if (isVariableDeclarationInitializedToRequire(declaration.parent) && isObjectBindingPattern(declaration.parent.name)) {
140345
+ for (const e of declaration.parent.name.elements) {
140346
+ const symbol = checker.getSymbolAtLocation(e.propertyName || e.name);
140347
+ if (symbol) {
140348
+ imports.add(skipAlias(symbol, checker));
140349
+ }
140350
+ }
140351
+ }
140352
+ }
140353
+ return imports;
140354
+ }
140339
140355
 
140340
140356
  // src/services/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.ts
140341
140357
  var ts_refactor_addOrRemoveBracesToArrowFunction_exports = {};
@@ -161549,7 +161565,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c
161549
161565
  }
161550
161566
  const keys = getOwnKeys(exports);
161551
161567
  const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
161552
- const conditions = getConditions(compilerOptions, mode === 99 /* ESNext */);
161568
+ const conditions = getConditions(compilerOptions, mode);
161553
161569
  addCompletionEntriesFromPathsOrExports(
161554
161570
  result,
161555
161571
  fragmentSubpath,
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.3";
38
- version = `${versionMajorMinor}.0-dev.20231030`;
38
+ version = `${versionMajorMinor}.0-dev.20231101`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -33165,7 +33165,8 @@ ${lanes.join("\n")}
33165
33165
  parseExpected(21 /* OpenParenToken */);
33166
33166
  let initializer;
33167
33167
  if (token() !== 27 /* SemicolonToken */) {
33168
- if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf)) {
33168
+ if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || // this one is meant to allow of
33169
+ token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine)) {
33169
33170
  initializer = parseVariableDeclarationList(
33170
33171
  /*inForStatementInitializer*/
33171
33172
  true
@@ -33486,12 +33487,6 @@ ${lanes.join("\n")}
33486
33487
  function isUsingDeclaration() {
33487
33488
  return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine);
33488
33489
  }
33489
- function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf() {
33490
- return nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(
33491
- /*disallowOf*/
33492
- true
33493
- );
33494
- }
33495
33490
  function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(disallowOf) {
33496
33491
  if (nextToken() === 160 /* UsingKeyword */) {
33497
33492
  return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf);
@@ -39547,8 +39542,7 @@ ${lanes.join("\n")}
39547
39542
  if (resolutionMode === 99 /* ESNext */ && (3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) {
39548
39543
  features |= 32 /* EsmMode */;
39549
39544
  }
39550
- const useImportCondition = resolutionMode === 99 /* ESNext */ || (resolutionMode !== void 0 ? false : void 0);
39551
- const conditions = features & 8 /* Exports */ ? getConditions(options, useImportCondition) : [];
39545
+ const conditions = features & 8 /* Exports */ ? getConditions(options, resolutionMode) : [];
39552
39546
  const diagnostics = [];
39553
39547
  const moduleResolutionState = {
39554
39548
  compilerOptions: options,
@@ -39716,16 +39710,16 @@ ${lanes.join("\n")}
39716
39710
  }
39717
39711
  return features;
39718
39712
  }
39719
- function getConditions(options, esmMode) {
39713
+ function getConditions(options, resolutionMode) {
39720
39714
  const moduleResolution = getEmitModuleResolutionKind(options);
39721
- if (esmMode === void 0) {
39715
+ if (resolutionMode === void 0) {
39722
39716
  if (moduleResolution === 100 /* Bundler */) {
39723
- esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */);
39717
+ resolutionMode = 99 /* ESNext */;
39724
39718
  } else if (moduleResolution === 2 /* Node10 */) {
39725
39719
  return [];
39726
39720
  }
39727
39721
  }
39728
- const conditions = esmMode ? ["import"] : ["require"];
39722
+ const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"];
39729
39723
  if (!options.noDtsResolution) {
39730
39724
  conditions.push("types");
39731
39725
  }
@@ -40174,13 +40168,13 @@ ${lanes.join("\n")}
40174
40168
  result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
40175
40169
  break;
40176
40170
  case 2 /* Node10 */:
40177
- result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
40171
+ result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
40178
40172
  break;
40179
40173
  case 1 /* Classic */:
40180
40174
  result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
40181
40175
  break;
40182
40176
  case 100 /* Bundler */:
40183
- result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
40177
+ result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
40184
40178
  break;
40185
40179
  default:
40186
40180
  return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
@@ -40445,7 +40439,7 @@ ${lanes.join("\n")}
40445
40439
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
40446
40440
  conditions ?? (conditions = getConditions(
40447
40441
  compilerOptions,
40448
- moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */)
40442
+ moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */
40449
40443
  ));
40450
40444
  const diagnostics = [];
40451
40445
  const state = {
@@ -40755,15 +40749,7 @@ ${lanes.join("\n")}
40755
40749
  entrypoints = append(entrypoints, mainResolution == null ? void 0 : mainResolution.path);
40756
40750
  if (features & 8 /* Exports */ && packageJsonInfo.contents.packageJsonContent.exports) {
40757
40751
  const conditionSets = deduplicate(
40758
- [getConditions(
40759
- options,
40760
- /*esmMode*/
40761
- true
40762
- ), getConditions(
40763
- options,
40764
- /*esmMode*/
40765
- false
40766
- )],
40752
+ [getConditions(options, 99 /* ESNext */), getConditions(options, 1 /* CommonJS */)],
40767
40753
  arrayIsEqualTo
40768
40754
  );
40769
40755
  for (const conditions of conditionSets) {
@@ -45497,7 +45483,7 @@ ${lanes.join("\n")}
45497
45483
  if (getResolvePackageJsonExports(options)) {
45498
45484
  const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
45499
45485
  const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
45500
- const conditions = getConditions(options, importMode === 99 /* ESNext */);
45486
+ const conditions = getConditions(options, importMode);
45501
45487
  const fromExports = packageJsonContent.exports ? tryGetModuleNameFromExports(options, path, packageRootPath, packageName2, packageJsonContent.exports, conditions) : void 0;
45502
45488
  if (fromExports) {
45503
45489
  const withJsExtension = !hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
@@ -80228,7 +80214,7 @@ ${lanes.join("\n")}
80228
80214
  }
80229
80215
  forEach(node.name.elements, checkSourceElement);
80230
80216
  }
80231
- if (isParameter(node) && node.initializer && nodeIsMissing(getContainingFunction(node).body)) {
80217
+ if (node.initializer && isParameterDeclaration(node) && nodeIsMissing(getContainingFunction(node).body)) {
80232
80218
  error2(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
80233
80219
  return;
80234
80220
  }
@@ -137828,14 +137814,13 @@ ${lanes.join("\n")}
137828
137814
  }
137829
137815
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
137830
137816
  const checker = program.getTypeChecker();
137831
- const usage = getUsageInfo(oldFile, toMove.all, checker);
137832
137817
  if (!host.fileExists(targetFile)) {
137833
- changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
137818
+ changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, getUsageInfo(oldFile, toMove.all, checker), changes, toMove, program, host, preferences));
137834
137819
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
137835
137820
  } else {
137836
137821
  const targetSourceFile = Debug.checkDefined(program.getSourceFile(targetFile));
137837
137822
  const importAdder = ts_codefix_exports.createImportAdder(targetSourceFile, context.program, context.preferences, context.host);
137838
- getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, usage, changes, toMove, program, host, preferences, importAdder);
137823
+ getNewStatementsAndRemoveFromOldFile2(oldFile, targetSourceFile, getUsageInfo(oldFile, toMove.all, checker, getExistingImports(targetSourceFile, checker)), changes, toMove, program, host, preferences, importAdder);
137839
137824
  }
137840
137825
  }
137841
137826
  function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences, importAdder) {
@@ -138501,7 +138486,7 @@ ${lanes.join("\n")}
138501
138486
  return false;
138502
138487
  }
138503
138488
  }
138504
- function getUsageInfo(oldFile, toMove, checker) {
138489
+ function getUsageInfo(oldFile, toMove, checker, existingTargetImports = /* @__PURE__ */ new Set()) {
138505
138490
  const movedSymbols = /* @__PURE__ */ new Set();
138506
138491
  const oldImportsNeededByTargetFile = /* @__PURE__ */ new Map();
138507
138492
  const targetFileImportsFromOldFile = /* @__PURE__ */ new Set();
@@ -138515,10 +138500,16 @@ ${lanes.join("\n")}
138515
138500
  movedSymbols.add(Debug.checkDefined(isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here"));
138516
138501
  });
138517
138502
  }
138503
+ const unusedImportsFromOldFile = /* @__PURE__ */ new Set();
138518
138504
  for (const statement of toMove) {
138519
138505
  forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
138520
- if (!symbol.declarations)
138506
+ if (!symbol.declarations) {
138507
+ return;
138508
+ }
138509
+ if (existingTargetImports.has(skipAlias(symbol, checker))) {
138510
+ unusedImportsFromOldFile.add(symbol);
138521
138511
  return;
138512
+ }
138522
138513
  for (const decl of symbol.declarations) {
138523
138514
  if (isInImport(decl)) {
138524
138515
  const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol);
@@ -138529,7 +138520,9 @@ ${lanes.join("\n")}
138529
138520
  }
138530
138521
  });
138531
138522
  }
138532
- const unusedImportsFromOldFile = new Set(oldImportsNeededByTargetFile.keys());
138523
+ for (const unusedImport of oldImportsNeededByTargetFile.keys()) {
138524
+ unusedImportsFromOldFile.add(unusedImport);
138525
+ }
138533
138526
  const oldFileImportsFromTargetFile = /* @__PURE__ */ new Set();
138534
138527
  for (const statement of oldFile.statements) {
138535
138528
  if (contains(toMove, statement))
@@ -138715,6 +138708,29 @@ ${lanes.join("\n")}
138715
138708
  }
138716
138709
  return void 0;
138717
138710
  }
138711
+ function getExistingImports(sourceFile, checker) {
138712
+ const imports = /* @__PURE__ */ new Set();
138713
+ for (const moduleSpecifier of sourceFile.imports) {
138714
+ const declaration = importFromModuleSpecifier(moduleSpecifier);
138715
+ if (isImportDeclaration(declaration) && declaration.importClause && declaration.importClause.namedBindings && isNamedImports(declaration.importClause.namedBindings)) {
138716
+ for (const e of declaration.importClause.namedBindings.elements) {
138717
+ const symbol = checker.getSymbolAtLocation(e.propertyName || e.name);
138718
+ if (symbol) {
138719
+ imports.add(skipAlias(symbol, checker));
138720
+ }
138721
+ }
138722
+ }
138723
+ if (isVariableDeclarationInitializedToRequire(declaration.parent) && isObjectBindingPattern(declaration.parent.name)) {
138724
+ for (const e of declaration.parent.name.elements) {
138725
+ const symbol = checker.getSymbolAtLocation(e.propertyName || e.name);
138726
+ if (symbol) {
138727
+ imports.add(skipAlias(symbol, checker));
138728
+ }
138729
+ }
138730
+ }
138731
+ }
138732
+ return imports;
138733
+ }
138718
138734
  var refactorNameForMoveToFile, description2, moveToFileAction;
138719
138735
  var init_moveToFile = __esm({
138720
138736
  "src/services/refactors/moveToFile.ts"() {
@@ -160818,7 +160834,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160818
160834
  }
160819
160835
  const keys = getOwnKeys(exports);
160820
160836
  const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
160821
- const conditions = getConditions(compilerOptions, mode === 99 /* ESNext */);
160837
+ const conditions = getConditions(compilerOptions, mode);
160822
160838
  addCompletionEntriesFromPathsOrExports(
160823
160839
  result,
160824
160840
  fragmentSubpath,
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.3";
57
- var version = `${versionMajorMinor}.0-dev.20231030`;
57
+ var version = `${versionMajorMinor}.0-dev.20231101`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -22502,7 +22502,8 @@ var Parser;
22502
22502
  parseExpected(21 /* OpenParenToken */);
22503
22503
  let initializer;
22504
22504
  if (token() !== 27 /* SemicolonToken */) {
22505
- if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf)) {
22505
+ if (token() === 115 /* VarKeyword */ || token() === 121 /* LetKeyword */ || token() === 87 /* ConstKeyword */ || token() === 160 /* UsingKeyword */ && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || // this one is meant to allow of
22506
+ token() === 135 /* AwaitKeyword */ && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine)) {
22506
22507
  initializer = parseVariableDeclarationList(
22507
22508
  /*inForStatementInitializer*/
22508
22509
  true
@@ -22823,12 +22824,6 @@ var Parser;
22823
22824
  function isUsingDeclaration() {
22824
22825
  return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine);
22825
22826
  }
22826
- function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf() {
22827
- return nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(
22828
- /*disallowOf*/
22829
- true
22830
- );
22831
- }
22832
22827
  function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(disallowOf) {
22833
22828
  if (nextToken() === 160 /* UsingKeyword */) {
22834
22829
  return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf);
@@ -27615,16 +27610,16 @@ function getNodeResolutionFeatures(options) {
27615
27610
  }
27616
27611
  return features;
27617
27612
  }
27618
- function getConditions(options, esmMode) {
27613
+ function getConditions(options, resolutionMode) {
27619
27614
  const moduleResolution = getEmitModuleResolutionKind(options);
27620
- if (esmMode === void 0) {
27615
+ if (resolutionMode === void 0) {
27621
27616
  if (moduleResolution === 100 /* Bundler */) {
27622
- esmMode ?? (esmMode = moduleResolution === 100 /* Bundler */);
27617
+ resolutionMode = 99 /* ESNext */;
27623
27618
  } else if (moduleResolution === 2 /* Node10 */) {
27624
27619
  return [];
27625
27620
  }
27626
27621
  }
27627
- const conditions = esmMode ? ["import"] : ["require"];
27622
+ const conditions = resolutionMode === 99 /* ESNext */ ? ["import"] : ["require"];
27628
27623
  if (!options.noDtsResolution) {
27629
27624
  conditions.push("types");
27630
27625
  }
@@ -27685,13 +27680,13 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
27685
27680
  result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
27686
27681
  break;
27687
27682
  case 2 /* Node10 */:
27688
- result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
27683
+ result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
27689
27684
  break;
27690
27685
  case 1 /* Classic */:
27691
27686
  result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
27692
27687
  break;
27693
27688
  case 100 /* Bundler */:
27694
- result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode === 99 /* ESNext */) : void 0);
27689
+ result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode ? getConditions(compilerOptions, resolutionMode) : void 0);
27695
27690
  break;
27696
27691
  default:
27697
27692
  return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
@@ -27938,7 +27933,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
27938
27933
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
27939
27934
  conditions ?? (conditions = getConditions(
27940
27935
  compilerOptions,
27941
- moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : !!(features & 32 /* EsmMode */)
27936
+ moduleResolution === 100 /* Bundler */ || moduleResolution === 2 /* Node10 */ ? void 0 : features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */
27942
27937
  ));
27943
27938
  const diagnostics = [];
27944
27939
  const state = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.3.0-dev.20231030",
5
+ "version": "5.3.0-dev.20231101",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "20.1.0",
115
115
  "npm": "8.19.4"
116
116
  },
117
- "gitHead": "f0374ce2a9c465e27a15b7fa4a347e2bd9079450"
117
+ "gitHead": "73bc0eba5fd35c3a31cc9a4e6d28d3e89564ce6f"
118
118
  }