typescript 5.1.1-rc → 5.1.5

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 = "5.1.1-rc";
21
+ var version = "5.1.5";
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?"),
@@ -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;
@@ -58057,7 +58055,10 @@ function createTypeChecker(host) {
58057
58055
  const newMapper = createTypeMapper(typeParameters, typeArguments);
58058
58056
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
58059
58057
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
58060
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
58058
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
58059
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
58060
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
58061
+ }
58061
58062
  }
58062
58063
  target.instantiations.set(id, result);
58063
58064
  }
@@ -58088,18 +58089,19 @@ function createTypeChecker(host) {
58088
58089
  case 185 /* TypeQuery */:
58089
58090
  const entityName = node2.exprName;
58090
58091
  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);
58092
+ if (!isThisIdentifier(firstIdentifier)) {
58093
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
58094
+ const tpDeclaration = tp.symbol.declarations[0];
58095
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
58096
+ // Type parameter is a regular type parameter, e.g. foo<T>
58097
+ tp.isThisType ? tpDeclaration : (
58098
+ // Type parameter is the this type, and its declaration is the class declaration.
58099
+ void 0
58100
+ )
58101
+ );
58102
+ if (firstIdentifierSymbol.declarations && tpScope) {
58103
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
58104
+ }
58103
58105
  }
58104
58106
  return true;
58105
58107
  case 173 /* MethodDeclaration */:
@@ -60582,7 +60584,6 @@ function createTypeChecker(host) {
60582
60584
  } else if (targetFlags & 8388608 /* IndexedAccess */) {
60583
60585
  if (sourceFlags & 8388608 /* IndexedAccess */) {
60584
60586
  if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
60585
- instantiateType(source2.objectType, reportUnreliableMapper);
60586
60587
  result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
60587
60588
  }
60588
60589
  if (result2) {
@@ -81638,7 +81639,7 @@ function createTypeChecker(host) {
81638
81639
  if (requestedExternalEmitHelperNames.has(name))
81639
81640
  continue;
81640
81641
  requestedExternalEmitHelperNames.add(name);
81641
- const symbol = getSymbol(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
81642
+ const symbol = resolveSymbol(getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
81642
81643
  if (!symbol) {
81643
81644
  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
81645
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -95307,7 +95308,7 @@ function transformJsx(context) {
95307
95308
  continue;
95308
95309
  }
95309
95310
  finishObjectLiteralIfNeeded();
95310
- expressions.push(attr.expression);
95311
+ expressions.push(Debug.checkDefined(visitNode(attr.expression, visitor, isExpression)));
95311
95312
  continue;
95312
95313
  }
95313
95314
  properties.push(transformJsxAttributeToObjectLiteralElement(attr));
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 = "5.1.1-rc";
2307
+ var version = "5.1.5";
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?"),
@@ -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;
@@ -62708,7 +62706,10 @@ function createTypeChecker(host) {
62708
62706
  const newMapper = createTypeMapper(typeParameters, typeArguments);
62709
62707
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
62710
62708
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
62711
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
62709
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
62710
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
62711
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
62712
+ }
62712
62713
  }
62713
62714
  target.instantiations.set(id, result);
62714
62715
  }
@@ -62739,18 +62740,19 @@ function createTypeChecker(host) {
62739
62740
  case 185 /* TypeQuery */:
62740
62741
  const entityName = node2.exprName;
62741
62742
  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);
62743
+ if (!isThisIdentifier(firstIdentifier)) {
62744
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
62745
+ const tpDeclaration = tp.symbol.declarations[0];
62746
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
62747
+ // Type parameter is a regular type parameter, e.g. foo<T>
62748
+ tp.isThisType ? tpDeclaration : (
62749
+ // Type parameter is the this type, and its declaration is the class declaration.
62750
+ void 0
62751
+ )
62752
+ );
62753
+ if (firstIdentifierSymbol.declarations && tpScope) {
62754
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
62755
+ }
62754
62756
  }
62755
62757
  return true;
62756
62758
  case 173 /* MethodDeclaration */:
@@ -65233,7 +65235,6 @@ function createTypeChecker(host) {
65233
65235
  } else if (targetFlags & 8388608 /* IndexedAccess */) {
65234
65236
  if (sourceFlags & 8388608 /* IndexedAccess */) {
65235
65237
  if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
65236
- instantiateType(source2.objectType, reportUnreliableMapper);
65237
65238
  result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
65238
65239
  }
65239
65240
  if (result2) {
@@ -86289,7 +86290,7 @@ function createTypeChecker(host) {
86289
86290
  if (requestedExternalEmitHelperNames.has(name))
86290
86291
  continue;
86291
86292
  requestedExternalEmitHelperNames.add(name);
86292
- const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
86293
+ const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
86293
86294
  if (!symbol) {
86294
86295
  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
86296
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -100129,7 +100130,7 @@ function transformJsx(context) {
100129
100130
  continue;
100130
100131
  }
100131
100132
  finishObjectLiteralIfNeeded();
100132
- expressions.push(attr.expression);
100133
+ expressions.push(Debug.checkDefined(visitNode(attr.expression, visitor, isExpression)));
100133
100134
  continue;
100134
100135
  }
100135
100136
  properties.push(transformJsxAttributeToObjectLiteralElement(attr));
@@ -136456,15 +136457,18 @@ registerRefactor(refactorNameForMoveToFile, {
136456
136457
  Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
136457
136458
  const statements = Debug.checkDefined(getStatementsToMove(context));
136458
136459
  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 };
136460
+ const targetFile = interactiveRefactorArguments.targetFile;
136461
+ if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
136462
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
136463
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
136464
+ }
136465
+ return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid) };
136461
136466
  }
136462
136467
  });
136463
136468
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
136464
- var _a;
136465
136469
  const checker = program.getTypeChecker();
136466
136470
  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) {
136471
+ if (!host.fileExists(targetFile)) {
136468
136472
  changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
136469
136473
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
136470
136474
  } else {
@@ -136502,6 +136506,13 @@ function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, chang
136502
136506
  if (typeof targetFile !== "string") {
136503
136507
  if (targetFile.statements.length > 0) {
136504
136508
  changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
136509
+ } else {
136510
+ changes.insertNodesAtEndOfFile(
136511
+ targetFile,
136512
+ body,
136513
+ /*blankLineBetween*/
136514
+ false
136515
+ );
136505
136516
  }
136506
136517
  if (imports.length > 0) {
136507
136518
  insertImports(
@@ -141839,7 +141850,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141839
141850
  onUnRecoverableConfigFileDiagnostic: noop
141840
141851
  };
141841
141852
  const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
141853
+ let releasedScriptKinds = /* @__PURE__ */ new Set();
141842
141854
  if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
141855
+ compilerHost = void 0;
141856
+ parsedCommandLines = void 0;
141857
+ releasedScriptKinds = void 0;
141843
141858
  return;
141844
141859
  }
141845
141860
  const options = {
@@ -141852,6 +141867,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141852
141867
  program = createProgram(options);
141853
141868
  compilerHost = void 0;
141854
141869
  parsedCommandLines = void 0;
141870
+ releasedScriptKinds = void 0;
141855
141871
  sourceMapper.clearCache();
141856
141872
  program.getTypeChecker();
141857
141873
  return;
@@ -141906,10 +141922,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141906
141922
  if (!shouldCreateNewSourceFile) {
141907
141923
  const oldSourceFile = program && program.getSourceFileByPath(path);
141908
141924
  if (oldSourceFile) {
141909
- if (scriptKind === oldSourceFile.scriptKind) {
141925
+ if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
141910
141926
  return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
141911
141927
  } else {
141912
141928
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
141929
+ releasedScriptKinds.add(oldSourceFile.resolvedPath);
141913
141930
  }
141914
141931
  }
141915
141932
  }
@@ -156296,7 +156313,7 @@ function getSourceFromOrigin(origin) {
156296
156313
  }
156297
156314
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol = false) {
156298
156315
  const start2 = timestamp();
156299
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken);
156316
+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken, location);
156300
156317
  const useSemicolons = probablyUsesSemicolons(sourceFile);
156301
156318
  const typeChecker = program.getTypeChecker();
156302
156319
  const uniques = /* @__PURE__ */ new Map();
@@ -158475,11 +158492,12 @@ function isModuleSpecifierMissingOrEmpty(specifier) {
158475
158492
  return true;
158476
158493
  return !((_a = tryCast(isExternalModuleReference(specifier) ? specifier.expression : specifier, isStringLiteralLike)) == null ? void 0 : _a.text);
158477
158494
  }
158478
- function getVariableOrParameterDeclaration(contextToken) {
158495
+ function getVariableOrParameterDeclaration(contextToken, location) {
158479
158496
  if (!contextToken)
158480
158497
  return;
158481
- const declaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node) || (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
158482
- return declaration;
158498
+ const possiblyParameterDeclaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
158499
+ const possiblyVariableDeclaration = findAncestor(location, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node));
158500
+ return possiblyParameterDeclaration || possiblyVariableDeclaration;
158483
158501
  }
158484
158502
  function isArrowFunctionBody(node) {
158485
158503
  return node.parent && isArrowFunction(node.parent) && (node.parent.body === node || // const a = () => /**/;
@@ -158721,7 +158739,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck
158721
158739
  case 290 /* JsxAttribute */:
158722
158740
  if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
158723
158741
  const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 290 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
158724
- return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType();
158742
+ return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(0 /* None */);
158725
158743
  }
158726
158744
  case 271 /* ImportDeclaration */:
158727
158745
  case 277 /* ExportDeclaration */:
@@ -165853,6 +165871,17 @@ var ChangeTracker = class {
165853
165871
  this.insertNodeAt(sourceFile, pos, insert, options);
165854
165872
  }
165855
165873
  }
165874
+ insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165875
+ this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165876
+ }
165877
+ insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165878
+ const pos = sourceFile.end + 1;
165879
+ const options = {
165880
+ prefix: this.newLineCharacter,
165881
+ suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165882
+ };
165883
+ this.insertNodesAt(sourceFile, pos, insert, options);
165884
+ }
165856
165885
  insertStatementsInNewFile(fileName, statements, oldFile) {
165857
165886
  if (!this.newFileChanges) {
165858
165887
  this.newFileChanges = createMultiMap();
@@ -181964,7 +181993,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
181964
181993
  return {
181965
181994
  renameLocation: mappedRenameLocation,
181966
181995
  renameFilename,
181967
- edits: this.mapTextChangesToCodeEdits(edits)
181996
+ edits: this.mapTextChangesToCodeEdits(edits),
181997
+ notApplicableReason: result.notApplicableReason
181968
181998
  };
181969
181999
  }
181970
182000
  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:
@@ -5445,7 +5446,6 @@ declare namespace ts {
5445
5446
  type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment;
5446
5447
  interface JsxSpreadAttribute extends ObjectLiteralElement {
5447
5448
  readonly kind: SyntaxKind.JsxSpreadAttribute;
5448
- readonly name: PropertyName;
5449
5449
  readonly parent: JsxAttributes;
5450
5450
  readonly expression: Expression;
5451
5451
  }
@@ -10190,7 +10190,7 @@ declare namespace ts {
10190
10190
  * arguments for any interactive action before offering it.
10191
10191
  */
10192
10192
  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;
10193
+ getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, interactiveRefactorArguments?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
10194
10194
  getMoveToRefactoringFileSuggestions(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): {
10195
10195
  newFileName: string;
10196
10196
  files: string[];
@@ -10480,6 +10480,7 @@ declare namespace ts {
10480
10480
  renameFilename?: string;
10481
10481
  renameLocation?: number;
10482
10482
  commands?: CodeActionCommand[];
10483
+ notApplicableReason?: string;
10483
10484
  }
10484
10485
  type RefactorTriggerReason = "implicit" | "invoked";
10485
10486
  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 = "5.1.1-rc";
38
+ version = "5.1.5";
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?"),
@@ -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;
@@ -60499,7 +60497,10 @@ ${lanes.join("\n")}
60499
60497
  const newMapper = createTypeMapper(typeParameters, typeArguments);
60500
60498
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
60501
60499
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60502
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
60500
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
60501
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60502
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
60503
+ }
60503
60504
  }
60504
60505
  target.instantiations.set(id, result);
60505
60506
  }
@@ -60530,18 +60531,19 @@ ${lanes.join("\n")}
60530
60531
  case 185 /* TypeQuery */:
60531
60532
  const entityName = node2.exprName;
60532
60533
  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);
60534
+ if (!isThisIdentifier(firstIdentifier)) {
60535
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60536
+ const tpDeclaration = tp.symbol.declarations[0];
60537
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
60538
+ // Type parameter is a regular type parameter, e.g. foo<T>
60539
+ tp.isThisType ? tpDeclaration : (
60540
+ // Type parameter is the this type, and its declaration is the class declaration.
60541
+ void 0
60542
+ )
60543
+ );
60544
+ if (firstIdentifierSymbol.declarations && tpScope) {
60545
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60546
+ }
60545
60547
  }
60546
60548
  return true;
60547
60549
  case 173 /* MethodDeclaration */:
@@ -63024,7 +63026,6 @@ ${lanes.join("\n")}
63024
63026
  } else if (targetFlags & 8388608 /* IndexedAccess */) {
63025
63027
  if (sourceFlags & 8388608 /* IndexedAccess */) {
63026
63028
  if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
63027
- instantiateType(source2.objectType, reportUnreliableMapper);
63028
63029
  result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
63029
63030
  }
63030
63031
  if (result2) {
@@ -84080,7 +84081,7 @@ ${lanes.join("\n")}
84080
84081
  if (requestedExternalEmitHelperNames.has(name))
84081
84082
  continue;
84082
84083
  requestedExternalEmitHelperNames.add(name);
84083
- const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
84084
+ const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
84084
84085
  if (!symbol) {
84085
84086
  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
84087
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -98155,7 +98156,7 @@ ${lanes.join("\n")}
98155
98156
  continue;
98156
98157
  }
98157
98158
  finishObjectLiteralIfNeeded();
98158
- expressions.push(attr.expression);
98159
+ expressions.push(Debug.checkDefined(visitNode(attr.expression, visitor, isExpression)));
98159
98160
  continue;
98160
98161
  }
98161
98162
  properties.push(transformJsxAttributeToObjectLiteralElement(attr));
@@ -134844,10 +134845,9 @@ ${lanes.join("\n")}
134844
134845
 
134845
134846
  // src/services/refactors/moveToFile.ts
134846
134847
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
134847
- var _a;
134848
134848
  const checker = program.getTypeChecker();
134849
134849
  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) {
134850
+ if (!host.fileExists(targetFile)) {
134851
134851
  changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
134852
134852
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
134853
134853
  } else {
@@ -134885,6 +134885,13 @@ ${lanes.join("\n")}
134885
134885
  if (typeof targetFile !== "string") {
134886
134886
  if (targetFile.statements.length > 0) {
134887
134887
  changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
134888
+ } else {
134889
+ changes.insertNodesAtEndOfFile(
134890
+ targetFile,
134891
+ body,
134892
+ /*blankLineBetween*/
134893
+ false
134894
+ );
134888
134895
  }
134889
134896
  if (imports.length > 0) {
134890
134897
  insertImports(
@@ -135703,8 +135710,12 @@ ${lanes.join("\n")}
135703
135710
  Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
135704
135711
  const statements = Debug.checkDefined(getStatementsToMove(context));
135705
135712
  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 };
135713
+ const targetFile = interactiveRefactorArguments.targetFile;
135714
+ if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
135715
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
135716
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
135717
+ }
135718
+ return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid) };
135708
135719
  }
135709
135720
  });
135710
135721
  }
@@ -139783,7 +139794,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139783
139794
  onUnRecoverableConfigFileDiagnostic: noop
139784
139795
  };
139785
139796
  const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
139797
+ let releasedScriptKinds = /* @__PURE__ */ new Set();
139786
139798
  if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
139799
+ compilerHost = void 0;
139800
+ parsedCommandLines = void 0;
139801
+ releasedScriptKinds = void 0;
139787
139802
  return;
139788
139803
  }
139789
139804
  const options = {
@@ -139796,6 +139811,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139796
139811
  program = createProgram(options);
139797
139812
  compilerHost = void 0;
139798
139813
  parsedCommandLines = void 0;
139814
+ releasedScriptKinds = void 0;
139799
139815
  sourceMapper.clearCache();
139800
139816
  program.getTypeChecker();
139801
139817
  return;
@@ -139850,10 +139866,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139850
139866
  if (!shouldCreateNewSourceFile) {
139851
139867
  const oldSourceFile = program && program.getSourceFileByPath(path);
139852
139868
  if (oldSourceFile) {
139853
- if (scriptKind === oldSourceFile.scriptKind) {
139869
+ if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
139854
139870
  return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
139855
139871
  } else {
139856
139872
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
139873
+ releasedScriptKinds.add(oldSourceFile.resolvedPath);
139857
139874
  }
139858
139875
  }
139859
139876
  }
@@ -155528,7 +155545,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
155528
155545
  }
155529
155546
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol = false) {
155530
155547
  const start = timestamp();
155531
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken);
155548
+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken, location);
155532
155549
  const useSemicolons = probablyUsesSemicolons(sourceFile);
155533
155550
  const typeChecker = program.getTypeChecker();
155534
155551
  const uniques = /* @__PURE__ */ new Map();
@@ -157685,11 +157702,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
157685
157702
  return true;
157686
157703
  return !((_a = tryCast(isExternalModuleReference(specifier) ? specifier.expression : specifier, isStringLiteralLike)) == null ? void 0 : _a.text);
157687
157704
  }
157688
- function getVariableOrParameterDeclaration(contextToken) {
157705
+ function getVariableOrParameterDeclaration(contextToken, location) {
157689
157706
  if (!contextToken)
157690
157707
  return;
157691
- const declaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node) || (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
157692
- return declaration;
157708
+ const possiblyParameterDeclaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
157709
+ const possiblyVariableDeclaration = findAncestor(location, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node));
157710
+ return possiblyParameterDeclaration || possiblyVariableDeclaration;
157693
157711
  }
157694
157712
  function isArrowFunctionBody(node) {
157695
157713
  return node.parent && isArrowFunction(node.parent) && (node.parent.body === node || // const a = () => /**/;
@@ -157996,7 +158014,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
157996
158014
  case 290 /* JsxAttribute */:
157997
158015
  if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
157998
158016
  const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 290 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
157999
- return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType();
158017
+ return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(0 /* None */);
158000
158018
  }
158001
158019
  case 271 /* ImportDeclaration */:
158002
158020
  case 277 /* ExportDeclaration */:
@@ -165722,6 +165740,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
165722
165740
  this.insertNodeAt(sourceFile, pos, insert, options);
165723
165741
  }
165724
165742
  }
165743
+ insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165744
+ this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165745
+ }
165746
+ insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165747
+ const pos = sourceFile.end + 1;
165748
+ const options = {
165749
+ prefix: this.newLineCharacter,
165750
+ suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165751
+ };
165752
+ this.insertNodesAt(sourceFile, pos, insert, options);
165753
+ }
165725
165754
  insertStatementsInNewFile(fileName, statements, oldFile) {
165726
165755
  if (!this.newFileChanges) {
165727
165756
  this.newFileChanges = createMultiMap();
@@ -179401,7 +179430,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
179401
179430
  return {
179402
179431
  renameLocation: mappedRenameLocation,
179403
179432
  renameFilename,
179404
- edits: this.mapTextChangesToCodeEdits(edits)
179433
+ edits: this.mapTextChangesToCodeEdits(edits),
179434
+ notApplicableReason: result.notApplicableReason
179405
179435
  };
179406
179436
  }
179407
179437
  return result;
@@ -1398,7 +1398,6 @@ declare namespace ts {
1398
1398
  type JsxAttributeValue = StringLiteral | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment;
1399
1399
  interface JsxSpreadAttribute extends ObjectLiteralElement {
1400
1400
  readonly kind: SyntaxKind.JsxSpreadAttribute;
1401
- readonly name: PropertyName;
1402
1401
  readonly parent: JsxAttributes;
1403
1402
  readonly expression: Expression;
1404
1403
  }
@@ -6227,7 +6226,7 @@ declare namespace ts {
6227
6226
  * arguments for any interactive action before offering it.
6228
6227
  */
6229
6228
  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;
6229
+ getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, interactiveRefactorArguments?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
6231
6230
  getMoveToRefactoringFileSuggestions(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): {
6232
6231
  newFileName: string;
6233
6232
  files: string[];
@@ -6517,6 +6516,7 @@ declare namespace ts {
6517
6516
  renameFilename?: string;
6518
6517
  renameLocation?: number;
6519
6518
  commands?: CodeActionCommand[];
6519
+ notApplicableReason?: string;
6520
6520
  }
6521
6521
  type RefactorTriggerReason = "implicit" | "invoked";
6522
6522
  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 = "5.1.1-rc";
38
+ version = "5.1.5";
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?"),
@@ -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;
@@ -60499,7 +60497,10 @@ ${lanes.join("\n")}
60499
60497
  const newMapper = createTypeMapper(typeParameters, typeArguments);
60500
60498
  result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
60501
60499
  if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60502
- result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
60500
+ const resultCouldContainTypeVariables = some(typeArguments, couldContainTypeVariables);
60501
+ if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
60502
+ result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
60503
+ }
60503
60504
  }
60504
60505
  target.instantiations.set(id, result);
60505
60506
  }
@@ -60530,18 +60531,19 @@ ${lanes.join("\n")}
60530
60531
  case 185 /* TypeQuery */:
60531
60532
  const entityName = node2.exprName;
60532
60533
  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);
60534
+ if (!isThisIdentifier(firstIdentifier)) {
60535
+ const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
60536
+ const tpDeclaration = tp.symbol.declarations[0];
60537
+ const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
60538
+ // Type parameter is a regular type parameter, e.g. foo<T>
60539
+ tp.isThisType ? tpDeclaration : (
60540
+ // Type parameter is the this type, and its declaration is the class declaration.
60541
+ void 0
60542
+ )
60543
+ );
60544
+ if (firstIdentifierSymbol.declarations && tpScope) {
60545
+ return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
60546
+ }
60545
60547
  }
60546
60548
  return true;
60547
60549
  case 173 /* MethodDeclaration */:
@@ -63024,7 +63026,6 @@ ${lanes.join("\n")}
63024
63026
  } else if (targetFlags & 8388608 /* IndexedAccess */) {
63025
63027
  if (sourceFlags & 8388608 /* IndexedAccess */) {
63026
63028
  if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
63027
- instantiateType(source2.objectType, reportUnreliableMapper);
63028
63029
  result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
63029
63030
  }
63030
63031
  if (result2) {
@@ -84080,7 +84081,7 @@ ${lanes.join("\n")}
84080
84081
  if (requestedExternalEmitHelperNames.has(name))
84081
84082
  continue;
84082
84083
  requestedExternalEmitHelperNames.add(name);
84083
- const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
84084
+ const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
84084
84085
  if (!symbol) {
84085
84086
  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
84087
  } else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -98155,7 +98156,7 @@ ${lanes.join("\n")}
98155
98156
  continue;
98156
98157
  }
98157
98158
  finishObjectLiteralIfNeeded();
98158
- expressions.push(attr.expression);
98159
+ expressions.push(Debug.checkDefined(visitNode(attr.expression, visitor, isExpression)));
98159
98160
  continue;
98160
98161
  }
98161
98162
  properties.push(transformJsxAttributeToObjectLiteralElement(attr));
@@ -134859,10 +134860,9 @@ ${lanes.join("\n")}
134859
134860
 
134860
134861
  // src/services/refactors/moveToFile.ts
134861
134862
  function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
134862
- var _a;
134863
134863
  const checker = program.getTypeChecker();
134864
134864
  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) {
134865
+ if (!host.fileExists(targetFile)) {
134866
134866
  changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
134867
134867
  addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
134868
134868
  } else {
@@ -134900,6 +134900,13 @@ ${lanes.join("\n")}
134900
134900
  if (typeof targetFile !== "string") {
134901
134901
  if (targetFile.statements.length > 0) {
134902
134902
  changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
134903
+ } else {
134904
+ changes.insertNodesAtEndOfFile(
134905
+ targetFile,
134906
+ body,
134907
+ /*blankLineBetween*/
134908
+ false
134909
+ );
134903
134910
  }
134904
134911
  if (imports.length > 0) {
134905
134912
  insertImports(
@@ -135718,8 +135725,12 @@ ${lanes.join("\n")}
135718
135725
  Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
135719
135726
  const statements = Debug.checkDefined(getStatementsToMove(context));
135720
135727
  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 };
135728
+ const targetFile = interactiveRefactorArguments.targetFile;
135729
+ if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
135730
+ const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
135731
+ return { edits, renameFilename: void 0, renameLocation: void 0 };
135732
+ }
135733
+ return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid) };
135723
135734
  }
135724
135735
  });
135725
135736
  }
@@ -139798,7 +139809,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139798
139809
  onUnRecoverableConfigFileDiagnostic: noop
139799
139810
  };
139800
139811
  const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
139812
+ let releasedScriptKinds = /* @__PURE__ */ new Set();
139801
139813
  if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
139814
+ compilerHost = void 0;
139815
+ parsedCommandLines = void 0;
139816
+ releasedScriptKinds = void 0;
139802
139817
  return;
139803
139818
  }
139804
139819
  const options = {
@@ -139811,6 +139826,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139811
139826
  program = createProgram(options);
139812
139827
  compilerHost = void 0;
139813
139828
  parsedCommandLines = void 0;
139829
+ releasedScriptKinds = void 0;
139814
139830
  sourceMapper.clearCache();
139815
139831
  program.getTypeChecker();
139816
139832
  return;
@@ -139865,10 +139881,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
139865
139881
  if (!shouldCreateNewSourceFile) {
139866
139882
  const oldSourceFile = program && program.getSourceFileByPath(path);
139867
139883
  if (oldSourceFile) {
139868
- if (scriptKind === oldSourceFile.scriptKind) {
139884
+ if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
139869
139885
  return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
139870
139886
  } else {
139871
139887
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
139888
+ releasedScriptKinds.add(oldSourceFile.resolvedPath);
139872
139889
  }
139873
139890
  }
139874
139891
  }
@@ -155543,7 +155560,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
155543
155560
  }
155544
155561
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol = false) {
155545
155562
  const start = timestamp();
155546
- const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken);
155563
+ const variableOrParameterDeclaration = getVariableOrParameterDeclaration(contextToken, location);
155547
155564
  const useSemicolons = probablyUsesSemicolons(sourceFile);
155548
155565
  const typeChecker = program.getTypeChecker();
155549
155566
  const uniques = /* @__PURE__ */ new Map();
@@ -157700,11 +157717,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
157700
157717
  return true;
157701
157718
  return !((_a = tryCast(isExternalModuleReference(specifier) ? specifier.expression : specifier, isStringLiteralLike)) == null ? void 0 : _a.text);
157702
157719
  }
157703
- function getVariableOrParameterDeclaration(contextToken) {
157720
+ function getVariableOrParameterDeclaration(contextToken, location) {
157704
157721
  if (!contextToken)
157705
157722
  return;
157706
- const declaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node) || (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
157707
- return declaration;
157723
+ const possiblyParameterDeclaration = findAncestor(contextToken, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : (isParameter(node) || isTypeParameterDeclaration(node)) && !isIndexSignatureDeclaration(node.parent));
157724
+ const possiblyVariableDeclaration = findAncestor(location, (node) => isFunctionBlock(node) || isArrowFunctionBody(node) || isBindingPattern(node) ? "quit" : isVariableDeclaration(node));
157725
+ return possiblyParameterDeclaration || possiblyVariableDeclaration;
157708
157726
  }
157709
157727
  function isArrowFunctionBody(node) {
157710
157728
  return node.parent && isArrowFunction(node.parent) && (node.parent.body === node || // const a = () => /**/;
@@ -158011,7 +158029,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
158011
158029
  case 290 /* JsxAttribute */:
158012
158030
  if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
158013
158031
  const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 290 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
158014
- return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType();
158032
+ return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(0 /* None */);
158015
158033
  }
158016
158034
  case 271 /* ImportDeclaration */:
158017
158035
  case 277 /* ExportDeclaration */:
@@ -165737,6 +165755,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
165737
165755
  this.insertNodeAt(sourceFile, pos, insert, options);
165738
165756
  }
165739
165757
  }
165758
+ insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165759
+ this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165760
+ }
165761
+ insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165762
+ const pos = sourceFile.end + 1;
165763
+ const options = {
165764
+ prefix: this.newLineCharacter,
165765
+ suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165766
+ };
165767
+ this.insertNodesAt(sourceFile, pos, insert, options);
165768
+ }
165740
165769
  insertStatementsInNewFile(fileName, statements, oldFile) {
165741
165770
  if (!this.newFileChanges) {
165742
165771
  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 = "5.1.1-rc";
57
+ var version = "5.1.5";
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.1-rc",
5
+ "version": "5.1.5",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [