typescript 5.1.0-dev.20230515 → 5.1.3

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.1";
21
- var version = `${versionMajorMinor}.0-dev.20230515`;
21
+ var version = "5.1.3";
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -7704,6 +7704,7 @@ var Diagnostics = {
7704
7704
  Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
7705
7705
  Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
7706
7706
  Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
7707
+ Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
7707
7708
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
7708
7709
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
7709
7710
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -23366,10 +23367,10 @@ var esDecorateHelper = {
23366
23367
  if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23367
23368
  if (_ = accept(result.get)) descriptor.get = _;
23368
23369
  if (_ = accept(result.set)) descriptor.set = _;
23369
- if (_ = accept(result.init)) initializers.push(_);
23370
+ if (_ = accept(result.init)) initializers.unshift(_);
23370
23371
  }
23371
23372
  else if (_ = accept(result)) {
23372
- if (kind === "field") initializers.push(_);
23373
+ if (kind === "field") initializers.unshift(_);
23373
23374
  else descriptor[key] = _;
23374
23375
  }
23375
23376
  }
@@ -53984,7 +53985,7 @@ function createTypeChecker(host) {
53984
53985
  } else if (type !== firstType) {
53985
53986
  checkFlags |= 64 /* HasNonUniformType */;
53986
53987
  }
53987
- if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
53988
+ if (isLiteralType(type) || isPatternLiteralType(type)) {
53988
53989
  checkFlags |= 128 /* HasLiteralType */;
53989
53990
  }
53990
53991
  if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
@@ -56183,31 +56184,28 @@ function createTypeChecker(host) {
56183
56184
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
56184
56185
  }
56185
56186
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
56186
- let first2;
56187
+ let last2;
56187
56188
  const types = [];
56188
56189
  for (const sig of signatures) {
56189
56190
  const pred = getTypePredicateOfSignature(sig);
56190
- if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
56191
- if (kind !== 2097152 /* Intersection */) {
56192
- continue;
56193
- } else {
56194
- return;
56195
- }
56196
- }
56197
- if (first2) {
56198
- if (!typePredicateKindsMatch(first2, pred)) {
56191
+ if (pred) {
56192
+ if (pred.kind !== 0 /* This */ && pred.kind !== 1 /* Identifier */ || last2 && !typePredicateKindsMatch(last2, pred)) {
56199
56193
  return void 0;
56200
56194
  }
56195
+ last2 = pred;
56196
+ types.push(pred.type);
56201
56197
  } else {
56202
- first2 = pred;
56198
+ const returnType = kind !== 2097152 /* Intersection */ ? getReturnTypeOfSignature(sig) : void 0;
56199
+ if (returnType !== falseType && returnType !== regularFalseType) {
56200
+ return void 0;
56201
+ }
56203
56202
  }
56204
- types.push(pred.type);
56205
56203
  }
56206
- if (!first2) {
56204
+ if (!last2) {
56207
56205
  return void 0;
56208
56206
  }
56209
56207
  const compositeType = getUnionOrIntersectionType(types, kind);
56210
- return createTypePredicate(first2.kind, first2.parameterName, first2.parameterIndex, compositeType);
56208
+ return createTypePredicate(last2.kind, last2.parameterName, last2.parameterIndex, compositeType);
56211
56209
  }
56212
56210
  function typePredicateKindsMatch(a, b) {
56213
56211
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
@@ -58088,18 +58086,19 @@ function createTypeChecker(host) {
58088
58086
  case 185 /* TypeQuery */:
58089
58087
  const entityName = node2.exprName;
58090
58088
  const firstIdentifier = getFirstIdentifier(entityName);
58091
- const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
58092
- const tpDeclaration = tp.symbol.declarations[0];
58093
- let tpScope;
58094
- if (tpDeclaration.kind === 167 /* TypeParameter */) {
58095
- tpScope = tpDeclaration.parent;
58096
- } else if (tp.isThisType) {
58097
- tpScope = tpDeclaration;
58098
- } else {
58099
- return true;
58100
- }
58101
- if (firstIdentifierSymbol.declarations) {
58102
- return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
58089
+ if (!isThisIdentifier(firstIdentifier)) {
58090
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
58091
+ const tpDeclaration = tp.symbol.declarations[0];
58092
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
58093
+ // Type parameter is a regular type parameter, e.g. foo<T>
58094
+ tp.isThisType ? tpDeclaration : (
58095
+ // Type parameter is the this type, and its declaration is the class declaration.
58096
+ void 0
58097
+ )
58098
+ );
58099
+ if (firstIdentifierSymbol.declarations && tpScope) {
58100
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
58101
+ }
58103
58102
  }
58104
58103
  return true;
58105
58104
  case 173 /* MethodDeclaration */:
@@ -81638,7 +81637,7 @@ function createTypeChecker(host) {
81638
81637
  if (requestedExternalEmitHelperNames.has(name))
81639
81638
  continue;
81640
81639
  requestedExternalEmitHelperNames.add(name);
81641
- const symbol = getSymbol(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
81640
+ const symbol = resolveSymbol(getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
81642
81641
  if (!symbol) {
81643
81642
  error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
81644
81643
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
package/lib/tsserver.js CHANGED
@@ -2304,7 +2304,7 @@ module.exports = __toCommonJS(server_exports);
2304
2304
 
2305
2305
  // src/compiler/corePublic.ts
2306
2306
  var versionMajorMinor = "5.1";
2307
- var version = `${versionMajorMinor}.0-dev.20230515`;
2307
+ var version = "5.1.3";
2308
2308
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2309
2309
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2310
2310
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -11212,6 +11212,7 @@ var Diagnostics = {
11212
11212
  Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
11213
11213
  Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
11214
11214
  Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
11215
+ Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
11215
11216
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
11216
11217
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
11217
11218
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -27617,10 +27618,10 @@ var esDecorateHelper = {
27617
27618
  if (result === null || typeof result !== "object") throw new TypeError("Object expected");
27618
27619
  if (_ = accept(result.get)) descriptor.get = _;
27619
27620
  if (_ = accept(result.set)) descriptor.set = _;
27620
- if (_ = accept(result.init)) initializers.push(_);
27621
+ if (_ = accept(result.init)) initializers.unshift(_);
27621
27622
  }
27622
27623
  else if (_ = accept(result)) {
27623
- if (kind === "field") initializers.push(_);
27624
+ if (kind === "field") initializers.unshift(_);
27624
27625
  else descriptor[key] = _;
27625
27626
  }
27626
27627
  }
@@ -58635,7 +58636,7 @@ function createTypeChecker(host) {
58635
58636
  } else if (type !== firstType) {
58636
58637
  checkFlags |= 64 /* HasNonUniformType */;
58637
58638
  }
58638
- if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
58639
+ if (isLiteralType(type) || isPatternLiteralType(type)) {
58639
58640
  checkFlags |= 128 /* HasLiteralType */;
58640
58641
  }
58641
58642
  if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
@@ -60834,31 +60835,28 @@ function createTypeChecker(host) {
60834
60835
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
60835
60836
  }
60836
60837
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
60837
- let first2;
60838
+ let last2;
60838
60839
  const types = [];
60839
60840
  for (const sig of signatures) {
60840
60841
  const pred = getTypePredicateOfSignature(sig);
60841
- if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
60842
- if (kind !== 2097152 /* Intersection */) {
60843
- continue;
60844
- } else {
60845
- return;
60846
- }
60847
- }
60848
- if (first2) {
60849
- if (!typePredicateKindsMatch(first2, pred)) {
60842
+ if (pred) {
60843
+ if (pred.kind !== 0 /* This */ && pred.kind !== 1 /* Identifier */ || last2 && !typePredicateKindsMatch(last2, pred)) {
60850
60844
  return void 0;
60851
60845
  }
60846
+ last2 = pred;
60847
+ types.push(pred.type);
60852
60848
  } else {
60853
- first2 = pred;
60849
+ const returnType = kind !== 2097152 /* Intersection */ ? getReturnTypeOfSignature(sig) : void 0;
60850
+ if (returnType !== falseType && returnType !== regularFalseType) {
60851
+ return void 0;
60852
+ }
60854
60853
  }
60855
- types.push(pred.type);
60856
60854
  }
60857
- if (!first2) {
60855
+ if (!last2) {
60858
60856
  return void 0;
60859
60857
  }
60860
60858
  const compositeType = getUnionOrIntersectionType(types, kind);
60861
- return createTypePredicate(first2.kind, first2.parameterName, first2.parameterIndex, compositeType);
60859
+ return createTypePredicate(last2.kind, last2.parameterName, last2.parameterIndex, compositeType);
60862
60860
  }
60863
60861
  function typePredicateKindsMatch(a, b) {
60864
60862
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
@@ -62739,18 +62737,19 @@ function createTypeChecker(host) {
62739
62737
  case 185 /* TypeQuery */:
62740
62738
  const entityName = node2.exprName;
62741
62739
  const firstIdentifier = getFirstIdentifier(entityName);
62742
- const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
62743
- const tpDeclaration = tp.symbol.declarations[0];
62744
- let tpScope;
62745
- if (tpDeclaration.kind === 167 /* TypeParameter */) {
62746
- tpScope = tpDeclaration.parent;
62747
- } else if (tp.isThisType) {
62748
- tpScope = tpDeclaration;
62749
- } else {
62750
- return true;
62751
- }
62752
- if (firstIdentifierSymbol.declarations) {
62753
- return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
62740
+ if (!isThisIdentifier(firstIdentifier)) {
62741
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
62742
+ const tpDeclaration = tp.symbol.declarations[0];
62743
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
62744
+ // Type parameter is a regular type parameter, e.g. foo<T>
62745
+ tp.isThisType ? tpDeclaration : (
62746
+ // Type parameter is the this type, and its declaration is the class declaration.
62747
+ void 0
62748
+ )
62749
+ );
62750
+ if (firstIdentifierSymbol.declarations && tpScope) {
62751
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
62752
+ }
62754
62753
  }
62755
62754
  return true;
62756
62755
  case 173 /* MethodDeclaration */:
@@ -86289,7 +86288,7 @@ function createTypeChecker(host) {
86289
86288
  if (requestedExternalEmitHelperNames.has(name))
86290
86289
  continue;
86291
86290
  requestedExternalEmitHelperNames.add(name);
86292
- const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
86291
+ const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
86293
86292
  if (!symbol) {
86294
86293
  error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
86295
86294
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -136456,15 +136455,18 @@ registerRefactor(refactorNameForMoveToFile, {
136456
136455
  Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
136457
136456
  const statements = Debug.checkDefined(getStatementsToMove(context));
136458
136457
  Debug.assert(interactiveRefactorArguments, "No interactive refactor arguments available");
136459
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
136460
- return { edits, renameFilename: void 0, renameLocation: void 0 };
136458
+ const targetFile = interactiveRefactorArguments.targetFile;
136459
+ if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
136460
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
136461
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
136462
+ }
136463
+ return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid) };
136461
136464
  }
136462
136465
  });
136463
136466
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
136464
- var _a;
136465
136467
  const checker = program.getTypeChecker();
136466
136468
  const usage = getUsageInfo(oldFile, toMove.all, checker);
136467
- if (!host.fileExists(targetFile) || host.fileExists(targetFile) && ((_a = program.getSourceFile(targetFile)) == null ? void 0 : _a.statements.length) === 0) {
136469
+ if (!host.fileExists(targetFile)) {
136468
136470
  changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
136469
136471
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
136470
136472
  } else {
@@ -136502,6 +136504,13 @@ function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, chang
136502
136504
  if (typeof targetFile !== "string") {
136503
136505
  if (targetFile.statements.length > 0) {
136504
136506
  changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
136507
+ } else {
136508
+ changes.insertNodesAtEndOfFile(
136509
+ targetFile,
136510
+ body,
136511
+ /*blankLineBetween*/
136512
+ false
136513
+ );
136505
136514
  }
136506
136515
  if (imports.length > 0) {
136507
136516
  insertImports(
@@ -141839,7 +141848,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141839
141848
  onUnRecoverableConfigFileDiagnostic: noop
141840
141849
  };
141841
141850
  const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
141851
+ let releasedScriptKinds = /* @__PURE__ */ new Set();
141842
141852
  if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
141853
+ compilerHost = void 0;
141854
+ parsedCommandLines = void 0;
141855
+ releasedScriptKinds = void 0;
141843
141856
  return;
141844
141857
  }
141845
141858
  const options = {
@@ -141852,6 +141865,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141852
141865
  program = createProgram(options);
141853
141866
  compilerHost = void 0;
141854
141867
  parsedCommandLines = void 0;
141868
+ releasedScriptKinds = void 0;
141855
141869
  sourceMapper.clearCache();
141856
141870
  program.getTypeChecker();
141857
141871
  return;
@@ -141906,10 +141920,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141906
141920
  if (!shouldCreateNewSourceFile) {
141907
141921
  const oldSourceFile = program && program.getSourceFileByPath(path);
141908
141922
  if (oldSourceFile) {
141909
- if (scriptKind === oldSourceFile.scriptKind) {
141923
+ if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
141910
141924
  return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
141911
141925
  } else {
141912
141926
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
141927
+ releasedScriptKinds.add(oldSourceFile.resolvedPath);
141913
141928
  }
141914
141929
  }
141915
141930
  }
@@ -165853,6 +165868,17 @@ var ChangeTracker = class {
165853
165868
  this.insertNodeAt(sourceFile, pos, insert, options);
165854
165869
  }
165855
165870
  }
165871
+ insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165872
+ this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165873
+ }
165874
+ insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165875
+ const pos = sourceFile.end + 1;
165876
+ const options = {
165877
+ prefix: this.newLineCharacter,
165878
+ suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165879
+ };
165880
+ this.insertNodesAt(sourceFile, pos, insert, options);
165881
+ }
165856
165882
  insertStatementsInNewFile(fileName, statements, oldFile) {
165857
165883
  if (!this.newFileChanges) {
165858
165884
  this.newFileChanges = createMultiMap();
@@ -181964,7 +181990,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
181964
181990
  return {
181965
181991
  renameLocation: mappedRenameLocation,
181966
181992
  renameFilename,
181967
- edits: this.mapTextChangesToCodeEdits(edits)
181993
+ edits: this.mapTextChangesToCodeEdits(edits),
181994
+ notApplicableReason: result.notApplicableReason
181968
181995
  };
181969
181996
  }
181970
181997
  return result;
@@ -619,6 +619,7 @@ declare namespace ts {
619
619
  */
620
620
  renameLocation?: Location;
621
621
  renameFilename?: string;
622
+ notApplicableReason?: string;
622
623
  }
623
624
  /**
624
625
  * Organize imports by:
@@ -10190,7 +10191,7 @@ declare namespace ts {
10190
10191
  * arguments for any interactive action before offering it.
10191
10192
  */
10192
10193
  getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string, includeInteractiveActions?: boolean): ApplicableRefactorInfo[];
10193
- getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, includeInteractiveActions?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
10194
+ getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, interactiveRefactorArguments?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
10194
10195
  getMoveToRefactoringFileSuggestions(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): {
10195
10196
  newFileName: string;
10196
10197
  files: string[];
@@ -10480,6 +10481,7 @@ declare namespace ts {
10480
10481
  renameFilename?: string;
10481
10482
  renameLocation?: number;
10482
10483
  commands?: CodeActionCommand[];
10484
+ notApplicableReason?: string;
10483
10485
  }
10484
10486
  type RefactorTriggerReason = "implicit" | "invoked";
10485
10487
  interface TextInsertion {
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230515`;
38
+ version = "5.1.3";
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9018,6 +9018,7 @@ ${lanes.join("\n")}
9018
9018
  Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
9019
9019
  Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
9020
9020
  Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
9021
+ Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
9021
9022
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
9022
9023
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
9023
9024
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -25516,10 +25517,10 @@ ${lanes.join("\n")}
25516
25517
  if (result === null || typeof result !== "object") throw new TypeError("Object expected");
25517
25518
  if (_ = accept(result.get)) descriptor.get = _;
25518
25519
  if (_ = accept(result.set)) descriptor.set = _;
25519
- if (_ = accept(result.init)) initializers.push(_);
25520
+ if (_ = accept(result.init)) initializers.unshift(_);
25520
25521
  }
25521
25522
  else if (_ = accept(result)) {
25522
- if (kind === "field") initializers.push(_);
25523
+ if (kind === "field") initializers.unshift(_);
25523
25524
  else descriptor[key] = _;
25524
25525
  }
25525
25526
  }
@@ -56426,7 +56427,7 @@ ${lanes.join("\n")}
56426
56427
  } else if (type !== firstType) {
56427
56428
  checkFlags |= 64 /* HasNonUniformType */;
56428
56429
  }
56429
- if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
56430
+ if (isLiteralType(type) || isPatternLiteralType(type)) {
56430
56431
  checkFlags |= 128 /* HasLiteralType */;
56431
56432
  }
56432
56433
  if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
@@ -58625,31 +58626,28 @@ ${lanes.join("\n")}
58625
58626
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
58626
58627
  }
58627
58628
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
58628
- let first2;
58629
+ let last2;
58629
58630
  const types = [];
58630
58631
  for (const sig of signatures) {
58631
58632
  const pred = getTypePredicateOfSignature(sig);
58632
- if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
58633
- if (kind !== 2097152 /* Intersection */) {
58634
- continue;
58635
- } else {
58636
- return;
58637
- }
58638
- }
58639
- if (first2) {
58640
- if (!typePredicateKindsMatch(first2, pred)) {
58633
+ if (pred) {
58634
+ if (pred.kind !== 0 /* This */ && pred.kind !== 1 /* Identifier */ || last2 && !typePredicateKindsMatch(last2, pred)) {
58641
58635
  return void 0;
58642
58636
  }
58637
+ last2 = pred;
58638
+ types.push(pred.type);
58643
58639
  } else {
58644
- first2 = pred;
58640
+ const returnType = kind !== 2097152 /* Intersection */ ? getReturnTypeOfSignature(sig) : void 0;
58641
+ if (returnType !== falseType && returnType !== regularFalseType) {
58642
+ return void 0;
58643
+ }
58645
58644
  }
58646
- types.push(pred.type);
58647
58645
  }
58648
- if (!first2) {
58646
+ if (!last2) {
58649
58647
  return void 0;
58650
58648
  }
58651
58649
  const compositeType = getUnionOrIntersectionType(types, kind);
58652
- return createTypePredicate(first2.kind, first2.parameterName, first2.parameterIndex, compositeType);
58650
+ return createTypePredicate(last2.kind, last2.parameterName, last2.parameterIndex, compositeType);
58653
58651
  }
58654
58652
  function typePredicateKindsMatch(a, b) {
58655
58653
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
@@ -60530,18 +60528,19 @@ ${lanes.join("\n")}
60530
60528
  case 185 /* TypeQuery */:
60531
60529
  const entityName = node2.exprName;
60532
60530
  const firstIdentifier = getFirstIdentifier(entityName);
60533
- const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60534
- const tpDeclaration = tp.symbol.declarations[0];
60535
- let tpScope;
60536
- if (tpDeclaration.kind === 167 /* TypeParameter */) {
60537
- tpScope = tpDeclaration.parent;
60538
- } else if (tp.isThisType) {
60539
- tpScope = tpDeclaration;
60540
- } else {
60541
- return true;
60542
- }
60543
- if (firstIdentifierSymbol.declarations) {
60544
- return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60531
+ if (!isThisIdentifier(firstIdentifier)) {
60532
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60533
+ const tpDeclaration = tp.symbol.declarations[0];
60534
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
60535
+ // Type parameter is a regular type parameter, e.g. foo<T>
60536
+ tp.isThisType ? tpDeclaration : (
60537
+ // Type parameter is the this type, and its declaration is the class declaration.
60538
+ void 0
60539
+ )
60540
+ );
60541
+ if (firstIdentifierSymbol.declarations && tpScope) {
60542
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60543
+ }
60545
60544
  }
60546
60545
  return true;
60547
60546
  case 173 /* MethodDeclaration */:
@@ -84080,7 +84079,7 @@ ${lanes.join("\n")}
84080
84079
  if (requestedExternalEmitHelperNames.has(name))
84081
84080
  continue;
84082
84081
  requestedExternalEmitHelperNames.add(name);
84083
- const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
84082
+ const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
84084
84083
  if (!symbol) {
84085
84084
  error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
84086
84085
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -134844,10 +134843,9 @@ ${lanes.join("\n")}
134844
134843
 
134845
134844
  // src/services/refactors/moveToFile.ts
134846
134845
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
134847
- var _a;
134848
134846
  const checker = program.getTypeChecker();
134849
134847
  const usage = getUsageInfo(oldFile, toMove.all, checker);
134850
- if (!host.fileExists(targetFile) || host.fileExists(targetFile) && ((_a = program.getSourceFile(targetFile)) == null ? void 0 : _a.statements.length) === 0) {
134848
+ if (!host.fileExists(targetFile)) {
134851
134849
  changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
134852
134850
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
134853
134851
  } else {
@@ -134885,6 +134883,13 @@ ${lanes.join("\n")}
134885
134883
  if (typeof targetFile !== "string") {
134886
134884
  if (targetFile.statements.length > 0) {
134887
134885
  changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
134886
+ } else {
134887
+ changes.insertNodesAtEndOfFile(
134888
+ targetFile,
134889
+ body,
134890
+ /*blankLineBetween*/
134891
+ false
134892
+ );
134888
134893
  }
134889
134894
  if (imports.length > 0) {
134890
134895
  insertImports(
@@ -135703,8 +135708,12 @@ ${lanes.join("\n")}
135703
135708
  Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
135704
135709
  const statements = Debug.checkDefined(getStatementsToMove(context));
135705
135710
  Debug.assert(interactiveRefactorArguments, "No interactive refactor arguments available");
135706
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
135707
- return { edits, renameFilename: void 0, renameLocation: void 0 };
135711
+ const targetFile = interactiveRefactorArguments.targetFile;
135712
+ if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
135713
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
135714
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
135715
+ }
135716
+ return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid) };
135708
135717
  }
135709
135718
  });
135710
135719
  }
@@ -139783,7 +139792,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139783
139792
  onUnRecoverableConfigFileDiagnostic: noop
139784
139793
  };
139785
139794
  const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
139795
+ let releasedScriptKinds = /* @__PURE__ */ new Set();
139786
139796
  if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
139797
+ compilerHost = void 0;
139798
+ parsedCommandLines = void 0;
139799
+ releasedScriptKinds = void 0;
139787
139800
  return;
139788
139801
  }
139789
139802
  const options = {
@@ -139796,6 +139809,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139796
139809
  program = createProgram(options);
139797
139810
  compilerHost = void 0;
139798
139811
  parsedCommandLines = void 0;
139812
+ releasedScriptKinds = void 0;
139799
139813
  sourceMapper.clearCache();
139800
139814
  program.getTypeChecker();
139801
139815
  return;
@@ -139850,10 +139864,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139850
139864
  if (!shouldCreateNewSourceFile) {
139851
139865
  const oldSourceFile = program && program.getSourceFileByPath(path);
139852
139866
  if (oldSourceFile) {
139853
- if (scriptKind === oldSourceFile.scriptKind) {
139867
+ if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
139854
139868
  return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
139855
139869
  } else {
139856
139870
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
139871
+ releasedScriptKinds.add(oldSourceFile.resolvedPath);
139857
139872
  }
139858
139873
  }
139859
139874
  }
@@ -165722,6 +165737,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
165722
165737
  this.insertNodeAt(sourceFile, pos, insert, options);
165723
165738
  }
165724
165739
  }
165740
+ insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165741
+ this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165742
+ }
165743
+ insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165744
+ const pos = sourceFile.end + 1;
165745
+ const options = {
165746
+ prefix: this.newLineCharacter,
165747
+ suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165748
+ };
165749
+ this.insertNodesAt(sourceFile, pos, insert, options);
165750
+ }
165725
165751
  insertStatementsInNewFile(fileName, statements, oldFile) {
165726
165752
  if (!this.newFileChanges) {
165727
165753
  this.newFileChanges = createMultiMap();
@@ -179401,7 +179427,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
179401
179427
  return {
179402
179428
  renameLocation: mappedRenameLocation,
179403
179429
  renameFilename,
179404
- edits: this.mapTextChangesToCodeEdits(edits)
179430
+ edits: this.mapTextChangesToCodeEdits(edits),
179431
+ notApplicableReason: result.notApplicableReason
179405
179432
  };
179406
179433
  }
179407
179434
  return result;
@@ -6227,7 +6227,7 @@ declare namespace ts {
6227
6227
  * arguments for any interactive action before offering it.
6228
6228
  */
6229
6229
  getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string, includeInteractiveActions?: boolean): ApplicableRefactorInfo[];
6230
- getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, includeInteractiveActions?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
6230
+ getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, interactiveRefactorArguments?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
6231
6231
  getMoveToRefactoringFileSuggestions(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): {
6232
6232
  newFileName: string;
6233
6233
  files: string[];
@@ -6517,6 +6517,7 @@ declare namespace ts {
6517
6517
  renameFilename?: string;
6518
6518
  renameLocation?: number;
6519
6519
  commands?: CodeActionCommand[];
6520
+ notApplicableReason?: string;
6520
6521
  }
6521
6522
  type RefactorTriggerReason = "implicit" | "invoked";
6522
6523
  interface TextInsertion {
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.1";
38
- version = `${versionMajorMinor}.0-dev.20230515`;
38
+ version = "5.1.3";
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -9018,6 +9018,7 @@ ${lanes.join("\n")}
9018
9018
  Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
9019
9019
  Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
9020
9020
  Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
9021
+ Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
9021
9022
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
9022
9023
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
9023
9024
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -25516,10 +25517,10 @@ ${lanes.join("\n")}
25516
25517
  if (result === null || typeof result !== "object") throw new TypeError("Object expected");
25517
25518
  if (_ = accept(result.get)) descriptor.get = _;
25518
25519
  if (_ = accept(result.set)) descriptor.set = _;
25519
- if (_ = accept(result.init)) initializers.push(_);
25520
+ if (_ = accept(result.init)) initializers.unshift(_);
25520
25521
  }
25521
25522
  else if (_ = accept(result)) {
25522
- if (kind === "field") initializers.push(_);
25523
+ if (kind === "field") initializers.unshift(_);
25523
25524
  else descriptor[key] = _;
25524
25525
  }
25525
25526
  }
@@ -56426,7 +56427,7 @@ ${lanes.join("\n")}
56426
56427
  } else if (type !== firstType) {
56427
56428
  checkFlags |= 64 /* HasNonUniformType */;
56428
56429
  }
56429
- if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
56430
+ if (isLiteralType(type) || isPatternLiteralType(type)) {
56430
56431
  checkFlags |= 128 /* HasLiteralType */;
56431
56432
  }
56432
56433
  if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
@@ -58625,31 +58626,28 @@ ${lanes.join("\n")}
58625
58626
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
58626
58627
  }
58627
58628
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
58628
- let first2;
58629
+ let last2;
58629
58630
  const types = [];
58630
58631
  for (const sig of signatures) {
58631
58632
  const pred = getTypePredicateOfSignature(sig);
58632
- if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
58633
- if (kind !== 2097152 /* Intersection */) {
58634
- continue;
58635
- } else {
58636
- return;
58637
- }
58638
- }
58639
- if (first2) {
58640
- if (!typePredicateKindsMatch(first2, pred)) {
58633
+ if (pred) {
58634
+ if (pred.kind !== 0 /* This */ && pred.kind !== 1 /* Identifier */ || last2 && !typePredicateKindsMatch(last2, pred)) {
58641
58635
  return void 0;
58642
58636
  }
58637
+ last2 = pred;
58638
+ types.push(pred.type);
58643
58639
  } else {
58644
- first2 = pred;
58640
+ const returnType = kind !== 2097152 /* Intersection */ ? getReturnTypeOfSignature(sig) : void 0;
58641
+ if (returnType !== falseType && returnType !== regularFalseType) {
58642
+ return void 0;
58643
+ }
58645
58644
  }
58646
- types.push(pred.type);
58647
58645
  }
58648
- if (!first2) {
58646
+ if (!last2) {
58649
58647
  return void 0;
58650
58648
  }
58651
58649
  const compositeType = getUnionOrIntersectionType(types, kind);
58652
- return createTypePredicate(first2.kind, first2.parameterName, first2.parameterIndex, compositeType);
58650
+ return createTypePredicate(last2.kind, last2.parameterName, last2.parameterIndex, compositeType);
58653
58651
  }
58654
58652
  function typePredicateKindsMatch(a, b) {
58655
58653
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
@@ -60530,18 +60528,19 @@ ${lanes.join("\n")}
60530
60528
  case 185 /* TypeQuery */:
60531
60529
  const entityName = node2.exprName;
60532
60530
  const firstIdentifier = getFirstIdentifier(entityName);
60533
- const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60534
- const tpDeclaration = tp.symbol.declarations[0];
60535
- let tpScope;
60536
- if (tpDeclaration.kind === 167 /* TypeParameter */) {
60537
- tpScope = tpDeclaration.parent;
60538
- } else if (tp.isThisType) {
60539
- tpScope = tpDeclaration;
60540
- } else {
60541
- return true;
60542
- }
60543
- if (firstIdentifierSymbol.declarations) {
60544
- return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60531
+ if (!isThisIdentifier(firstIdentifier)) {
60532
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60533
+ const tpDeclaration = tp.symbol.declarations[0];
60534
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
60535
+ // Type parameter is a regular type parameter, e.g. foo<T>
60536
+ tp.isThisType ? tpDeclaration : (
60537
+ // Type parameter is the this type, and its declaration is the class declaration.
60538
+ void 0
60539
+ )
60540
+ );
60541
+ if (firstIdentifierSymbol.declarations && tpScope) {
60542
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60543
+ }
60545
60544
  }
60546
60545
  return true;
60547
60546
  case 173 /* MethodDeclaration */:
@@ -84080,7 +84079,7 @@ ${lanes.join("\n")}
84080
84079
  if (requestedExternalEmitHelperNames.has(name))
84081
84080
  continue;
84082
84081
  requestedExternalEmitHelperNames.add(name);
84083
- const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
84082
+ const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
84084
84083
  if (!symbol) {
84085
84084
  error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
84086
84085
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -134859,10 +134858,9 @@ ${lanes.join("\n")}
134859
134858
 
134860
134859
  // src/services/refactors/moveToFile.ts
134861
134860
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
134862
- var _a;
134863
134861
  const checker = program.getTypeChecker();
134864
134862
  const usage = getUsageInfo(oldFile, toMove.all, checker);
134865
- if (!host.fileExists(targetFile) || host.fileExists(targetFile) && ((_a = program.getSourceFile(targetFile)) == null ? void 0 : _a.statements.length) === 0) {
134863
+ if (!host.fileExists(targetFile)) {
134866
134864
  changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
134867
134865
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
134868
134866
  } else {
@@ -134900,6 +134898,13 @@ ${lanes.join("\n")}
134900
134898
  if (typeof targetFile !== "string") {
134901
134899
  if (targetFile.statements.length > 0) {
134902
134900
  changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
134901
+ } else {
134902
+ changes.insertNodesAtEndOfFile(
134903
+ targetFile,
134904
+ body,
134905
+ /*blankLineBetween*/
134906
+ false
134907
+ );
134903
134908
  }
134904
134909
  if (imports.length > 0) {
134905
134910
  insertImports(
@@ -135718,8 +135723,12 @@ ${lanes.join("\n")}
135718
135723
  Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
135719
135724
  const statements = Debug.checkDefined(getStatementsToMove(context));
135720
135725
  Debug.assert(interactiveRefactorArguments, "No interactive refactor arguments available");
135721
- const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
135722
- return { edits, renameFilename: void 0, renameLocation: void 0 };
135726
+ const targetFile = interactiveRefactorArguments.targetFile;
135727
+ if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
135728
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
135729
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
135730
+ }
135731
+ return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid) };
135723
135732
  }
135724
135733
  });
135725
135734
  }
@@ -139798,7 +139807,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139798
139807
  onUnRecoverableConfigFileDiagnostic: noop
139799
139808
  };
139800
139809
  const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
139810
+ let releasedScriptKinds = /* @__PURE__ */ new Set();
139801
139811
  if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
139812
+ compilerHost = void 0;
139813
+ parsedCommandLines = void 0;
139814
+ releasedScriptKinds = void 0;
139802
139815
  return;
139803
139816
  }
139804
139817
  const options = {
@@ -139811,6 +139824,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139811
139824
  program = createProgram(options);
139812
139825
  compilerHost = void 0;
139813
139826
  parsedCommandLines = void 0;
139827
+ releasedScriptKinds = void 0;
139814
139828
  sourceMapper.clearCache();
139815
139829
  program.getTypeChecker();
139816
139830
  return;
@@ -139865,10 +139879,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139865
139879
  if (!shouldCreateNewSourceFile) {
139866
139880
  const oldSourceFile = program && program.getSourceFileByPath(path);
139867
139881
  if (oldSourceFile) {
139868
- if (scriptKind === oldSourceFile.scriptKind) {
139882
+ if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
139869
139883
  return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
139870
139884
  } else {
139871
139885
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
139886
+ releasedScriptKinds.add(oldSourceFile.resolvedPath);
139872
139887
  }
139873
139888
  }
139874
139889
  }
@@ -165737,6 +165752,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
165737
165752
  this.insertNodeAt(sourceFile, pos, insert, options);
165738
165753
  }
165739
165754
  }
165755
+ insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165756
+ this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165757
+ }
165758
+ insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165759
+ const pos = sourceFile.end + 1;
165760
+ const options = {
165761
+ prefix: this.newLineCharacter,
165762
+ suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165763
+ };
165764
+ this.insertNodesAt(sourceFile, pos, insert, options);
165765
+ }
165740
165766
  insertStatementsInNewFile(fileName, statements, oldFile) {
165741
165767
  if (!this.newFileChanges) {
165742
165768
  this.newFileChanges = createMultiMap();
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-dev.20230515`;
57
+ var version = "5.1.3";
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -7078,6 +7078,7 @@ var Diagnostics = {
7078
7078
  Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
7079
7079
  Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
7080
7080
  Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
7081
+ Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
7081
7082
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
7082
7083
  Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
7083
7084
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
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.1.0-dev.20230515",
5
+ "version": "5.1.3",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -112,6 +112,5 @@
112
112
  "volta": {
113
113
  "node": "20.1.0",
114
114
  "npm": "8.19.4"
115
- },
116
- "gitHead": "8fae437660ba89353fc7104beae8c6856528e5b6"
117
- }
115
+ }
116
+ }