typescript 5.6.0-dev.20240819 → 5.7.0-dev.20240820

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.
@@ -3595,7 +3595,7 @@ declare namespace ts {
3595
3595
  readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
3596
3596
  }
3597
3597
  }
3598
- const versionMajorMinor = "5.6";
3598
+ const versionMajorMinor = "5.7";
3599
3599
  /** The version of the TypeScript compiler release */
3600
3600
  const version: string;
3601
3601
  /**
@@ -6121,6 +6121,27 @@ declare namespace ts {
6121
6121
  getBaseTypes(type: InterfaceType): BaseType[];
6122
6122
  getBaseTypeOfLiteralType(type: Type): Type;
6123
6123
  getWidenedType(type: Type): Type;
6124
+ /**
6125
+ * Gets the "awaited type" of a type.
6126
+ *
6127
+ * If an expression has a Promise-like type, the "awaited type" of the expression is
6128
+ * derived from the type of the first argument of the fulfillment callback for that
6129
+ * Promise's `then` method. If the "awaited type" is itself a Promise-like, it is
6130
+ * recursively unwrapped in the same manner until a non-promise type is found.
6131
+ *
6132
+ * If an expression does not have a Promise-like type, its "awaited type" is the type
6133
+ * of the expression.
6134
+ *
6135
+ * If the resulting "awaited type" is a generic object type, then it is wrapped in
6136
+ * an `Awaited<T>`.
6137
+ *
6138
+ * In the event the "awaited type" circularly references itself, or is a non-Promise
6139
+ * object-type with a callable `then()` method, an "awaited type" cannot be determined
6140
+ * and the value `undefined` will be returned.
6141
+ *
6142
+ * This is used to reflect the runtime behavior of the `await` keyword.
6143
+ */
6144
+ getAwaitedType(type: Type): Type | undefined;
6124
6145
  getReturnTypeOfSignature(signature: Signature): Type;
6125
6146
  getNullableType(type: Type, flags: TypeFlags): Type;
6126
6147
  getNonNullableType(type: Type): Type;
package/lib/typescript.js CHANGED
@@ -2262,8 +2262,8 @@ __export(typescript_exports, {
2262
2262
  module.exports = __toCommonJS(typescript_exports);
2263
2263
 
2264
2264
  // src/compiler/corePublic.ts
2265
- var versionMajorMinor = "5.6";
2266
- var version = `${versionMajorMinor}.0-dev.20240819`;
2265
+ var versionMajorMinor = "5.7";
2266
+ var version = `${versionMajorMinor}.0-dev.20240820`;
2267
2267
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2268
2268
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2269
2269
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -75990,46 +75990,108 @@ function createTypeChecker(host) {
75990
75990
  function isCircularMappedProperty(symbol) {
75991
75991
  return !!(getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.links.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
75992
75992
  }
75993
+ function isExcludedMappedPropertyName(constraint, propertyNameType) {
75994
+ if (constraint.flags & 16777216 /* Conditional */) {
75995
+ const type = constraint;
75996
+ return !!(getReducedType(getTrueTypeFromConditionalType(type)).flags & 131072 /* Never */) && getActualTypeVariable(getFalseTypeFromConditionalType(type)) === getActualTypeVariable(type.checkType) && isTypeAssignableTo(propertyNameType, type.extendsType);
75997
+ }
75998
+ if (constraint.flags & 2097152 /* Intersection */) {
75999
+ return some(constraint.types, (t) => isExcludedMappedPropertyName(t, propertyNameType));
76000
+ }
76001
+ return false;
76002
+ }
75993
76003
  function getTypeOfPropertyOfContextualType(type, name, nameType) {
75994
76004
  return mapType(
75995
76005
  type,
75996
76006
  (t) => {
75997
- var _a;
75998
- if (isGenericMappedType(t) && getMappedTypeNameTypeKind(t) !== 2 /* Remapping */) {
75999
- const constraint = getConstraintTypeFromMappedType(t);
76000
- const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
76001
- const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
76002
- if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
76003
- return substituteIndexedMappedType(t, propertyNameType);
76004
- }
76005
- } else if (t.flags & 3670016 /* StructuredType */) {
76006
- const prop = getPropertyOfType(t, name);
76007
- if (prop) {
76008
- return isCircularMappedProperty(prop) ? void 0 : removeMissingType(getTypeOfSymbol(prop), !!(prop.flags & 16777216 /* Optional */));
76007
+ if (t.flags & 2097152 /* Intersection */) {
76008
+ let types;
76009
+ let indexInfoCandidates;
76010
+ let ignoreIndexInfos = false;
76011
+ for (const constituentType of t.types) {
76012
+ if (!(constituentType.flags & 524288 /* Object */)) {
76013
+ continue;
76014
+ }
76015
+ if (isGenericMappedType(constituentType) && getMappedTypeNameTypeKind(constituentType) !== 2 /* Remapping */) {
76016
+ const substitutedType = getIndexedMappedTypeSubstitutedTypeOfContextualType(constituentType, name, nameType);
76017
+ types = appendContextualPropertyTypeConstituent(types, substitutedType);
76018
+ continue;
76019
+ }
76020
+ const propertyType = getTypeOfConcretePropertyOfContextualType(constituentType, name);
76021
+ if (!propertyType) {
76022
+ if (!ignoreIndexInfos) {
76023
+ indexInfoCandidates = append(indexInfoCandidates, constituentType);
76024
+ }
76025
+ continue;
76026
+ }
76027
+ ignoreIndexInfos = true;
76028
+ indexInfoCandidates = void 0;
76029
+ types = appendContextualPropertyTypeConstituent(types, propertyType);
76009
76030
  }
76010
- if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
76011
- const restType = getElementTypeOfSliceOfTupleType(
76012
- t,
76013
- t.target.fixedLength,
76014
- /*endSkipCount*/
76015
- 0,
76016
- /*writing*/
76017
- false,
76018
- /*noReductions*/
76019
- true
76020
- );
76021
- if (restType) {
76022
- return restType;
76031
+ if (indexInfoCandidates) {
76032
+ for (const candidate of indexInfoCandidates) {
76033
+ const indexInfoType = getTypeFromIndexInfosOfContextualType(candidate, name, nameType);
76034
+ types = appendContextualPropertyTypeConstituent(types, indexInfoType);
76023
76035
  }
76024
76036
  }
76025
- return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
76037
+ if (!types) {
76038
+ return;
76039
+ }
76040
+ if (types.length === 1) {
76041
+ return types[0];
76042
+ }
76043
+ return getIntersectionType(types);
76026
76044
  }
76027
- return void 0;
76045
+ if (!(t.flags & 524288 /* Object */)) {
76046
+ return;
76047
+ }
76048
+ return isGenericMappedType(t) && getMappedTypeNameTypeKind(t) !== 2 /* Remapping */ ? getIndexedMappedTypeSubstitutedTypeOfContextualType(t, name, nameType) : getTypeOfConcretePropertyOfContextualType(t, name) ?? getTypeFromIndexInfosOfContextualType(t, name, nameType);
76028
76049
  },
76029
76050
  /*noReductions*/
76030
76051
  true
76031
76052
  );
76032
76053
  }
76054
+ function appendContextualPropertyTypeConstituent(types, type) {
76055
+ return type ? append(types, type.flags & 1 /* Any */ ? unknownType : type) : types;
76056
+ }
76057
+ function getIndexedMappedTypeSubstitutedTypeOfContextualType(type, name, nameType) {
76058
+ const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
76059
+ const constraint = getConstraintTypeFromMappedType(type);
76060
+ if (type.nameType && isExcludedMappedPropertyName(type.nameType, propertyNameType) || isExcludedMappedPropertyName(constraint, propertyNameType)) {
76061
+ return;
76062
+ }
76063
+ const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
76064
+ if (!isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
76065
+ return;
76066
+ }
76067
+ return substituteIndexedMappedType(type, propertyNameType);
76068
+ }
76069
+ function getTypeOfConcretePropertyOfContextualType(type, name) {
76070
+ const prop = getPropertyOfType(type, name);
76071
+ if (!prop || isCircularMappedProperty(prop)) {
76072
+ return;
76073
+ }
76074
+ return removeMissingType(getTypeOfSymbol(prop), !!(prop.flags & 16777216 /* Optional */));
76075
+ }
76076
+ function getTypeFromIndexInfosOfContextualType(type, name, nameType) {
76077
+ var _a;
76078
+ if (isTupleType(type) && isNumericLiteralName(name) && +name >= 0) {
76079
+ const restType = getElementTypeOfSliceOfTupleType(
76080
+ type,
76081
+ type.target.fixedLength,
76082
+ /*endSkipCount*/
76083
+ 0,
76084
+ /*writing*/
76085
+ false,
76086
+ /*noReductions*/
76087
+ true
76088
+ );
76089
+ if (restType) {
76090
+ return restType;
76091
+ }
76092
+ }
76093
+ return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(type), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
76094
+ }
76033
76095
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
76034
76096
  Debug.assert(isObjectLiteralMethod(node));
76035
76097
  if (node.flags & 67108864 /* InWithStatement */) {
@@ -163481,6 +163543,8 @@ var SortText = {
163481
163543
  return sortText + "1";
163482
163544
  }
163483
163545
  };
163546
+ var allCommitCharacters = [".", ",", ";"];
163547
+ var noCommaCommitCharacters = [".", ";"];
163484
163548
  var CompletionSource = /* @__PURE__ */ ((CompletionSource2) => {
163485
163549
  CompletionSource2["ThisProperty"] = "ThisProperty/";
163486
163550
  CompletionSource2["ClassMemberSnippet"] = "ClassMemberSnippet/";
@@ -163587,7 +163651,7 @@ function getDefaultCommitCharacters(isNewIdentifierLocation) {
163587
163651
  if (isNewIdentifierLocation) {
163588
163652
  return [];
163589
163653
  }
163590
- return [".", ",", ";"];
163654
+ return allCommitCharacters;
163591
163655
  }
163592
163656
  function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol = false) {
163593
163657
  var _a;
@@ -164085,7 +164149,8 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
164085
164149
  importStatementCompletion,
164086
164150
  insideJsDocTagTypeExpression,
164087
164151
  symbolToSortTextMap,
164088
- hasUnresolvedAutoImports
164152
+ hasUnresolvedAutoImports,
164153
+ defaultCommitCharacters
164089
164154
  } = completionData;
164090
164155
  let literals = completionData.literals;
164091
164156
  const checker = program.getTypeChecker();
@@ -164203,7 +164268,7 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
164203
164268
  isNewIdentifierLocation,
164204
164269
  optionalReplacementSpan: getOptionalReplacementSpan(location),
164205
164270
  entries,
164206
- defaultCommitCharacters: getDefaultCommitCharacters(isNewIdentifierLocation)
164271
+ defaultCommitCharacters: defaultCommitCharacters ?? getDefaultCommitCharacters(isNewIdentifierLocation)
164207
164272
  };
164208
164273
  }
164209
164274
  function isCheckedFile(sourceFile, compilerOptions) {
@@ -165602,6 +165667,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
165602
165667
  let keywordFilters = 0 /* None */;
165603
165668
  let isNewIdentifierLocation = false;
165604
165669
  let flags = 0 /* None */;
165670
+ let defaultCommitCharacters;
165605
165671
  if (contextToken) {
165606
165672
  const importStatementCompletionInfo = getImportStatementCompletionInfo(contextToken, sourceFile);
165607
165673
  if (importStatementCompletionInfo.keywordCompletion) {
@@ -165621,7 +165687,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
165621
165687
  }
165622
165688
  if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
165623
165689
  log("Returning an empty list because completion was requested in an invalid position.");
165624
- return keywordFilters ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierDefinitionLocation()) : void 0;
165690
+ return keywordFilters ? keywordCompletionData(keywordFilters, isJsOnlyLocation, computeCommitCharactersAndIsNewIdentifier().isNewIdentifierLocation) : void 0;
165625
165691
  }
165626
165692
  let parent2 = contextToken.parent;
165627
165693
  if (contextToken.kind === 25 /* DotToken */ || contextToken.kind === 29 /* QuestionDotToken */) {
@@ -165780,7 +165846,8 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
165780
165846
  isRightOfDotOrQuestionDot: isRightOfDot || isRightOfQuestionDot,
165781
165847
  importStatementCompletion,
165782
165848
  hasUnresolvedAutoImports,
165783
- flags
165849
+ flags,
165850
+ defaultCommitCharacters
165784
165851
  };
165785
165852
  function isTagWithTypeExpression(tag) {
165786
165853
  switch (tag.kind) {
@@ -165815,7 +165882,10 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
165815
165882
  const isRhsOfImportDeclaration = isInRightSideOfInternalImportEqualsDeclaration(node);
165816
165883
  if (isEntityName(node) || isImportType || isPropertyAccessExpression(node)) {
165817
165884
  const isNamespaceName = isModuleDeclaration(node.parent);
165818
- if (isNamespaceName) isNewIdentifierLocation = true;
165885
+ if (isNamespaceName) {
165886
+ isNewIdentifierLocation = true;
165887
+ defaultCommitCharacters = [];
165888
+ }
165819
165889
  let symbol = typeChecker.getSymbolAtLocation(node);
165820
165890
  if (symbol) {
165821
165891
  symbol = skipAlias(symbol, typeChecker);
@@ -165885,9 +165955,13 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
165885
165955
  }
165886
165956
  }
165887
165957
  function addTypeProperties(type, insertAwait, insertQuestionDot) {
165888
- isNewIdentifierLocation = !!type.getStringIndexType();
165958
+ if (type.getStringIndexType()) {
165959
+ isNewIdentifierLocation = true;
165960
+ defaultCommitCharacters = [];
165961
+ }
165889
165962
  if (isRightOfQuestionDot && some(type.getCallSignatures())) {
165890
165963
  isNewIdentifierLocation = true;
165964
+ defaultCommitCharacters ?? (defaultCommitCharacters = allCommitCharacters);
165891
165965
  }
165892
165966
  const propertyAccess = node.kind === 205 /* ImportType */ ? node : node.parent;
165893
165967
  if (inCheckedFile) {
@@ -166026,7 +166100,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
166026
166100
  function getGlobalCompletions() {
166027
166101
  keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */;
166028
166102
  completionKind = 1 /* Global */;
166029
- isNewIdentifierLocation = isNewIdentifierDefinitionLocation();
166103
+ ({ isNewIdentifierLocation, defaultCommitCharacters } = computeCommitCharactersAndIsNewIdentifier());
166030
166104
  if (previousToken !== contextToken) {
166031
166105
  Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'.");
166032
166106
  }
@@ -166292,41 +166366,109 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
166292
166366
  }
166293
166367
  return false;
166294
166368
  }
166295
- function isNewIdentifierDefinitionLocation() {
166369
+ function computeCommitCharactersAndIsNewIdentifier() {
166296
166370
  if (contextToken) {
166297
166371
  const containingNodeKind = contextToken.parent.kind;
166298
166372
  const tokenKind = keywordForNode(contextToken);
166299
166373
  switch (tokenKind) {
166300
166374
  case 28 /* CommaToken */:
166301
- return containingNodeKind === 213 /* CallExpression */ || containingNodeKind === 176 /* Constructor */ || containingNodeKind === 214 /* NewExpression */ || containingNodeKind === 209 /* ArrayLiteralExpression */ || containingNodeKind === 226 /* BinaryExpression */ || containingNodeKind === 184 /* FunctionType */ || containingNodeKind === 210 /* ObjectLiteralExpression */;
166375
+ switch (containingNodeKind) {
166376
+ case 213 /* CallExpression */:
166377
+ case 214 /* NewExpression */: {
166378
+ const expression = contextToken.parent.expression;
166379
+ if (getLineAndCharacterOfPosition(sourceFile, expression.end).line !== getLineAndCharacterOfPosition(sourceFile, position).line) {
166380
+ return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
166381
+ }
166382
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
166383
+ }
166384
+ case 226 /* BinaryExpression */:
166385
+ return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
166386
+ case 176 /* Constructor */:
166387
+ case 184 /* FunctionType */:
166388
+ case 210 /* ObjectLiteralExpression */:
166389
+ return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
166390
+ case 209 /* ArrayLiteralExpression */:
166391
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
166392
+ default:
166393
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166394
+ }
166302
166395
  case 21 /* OpenParenToken */:
166303
- return containingNodeKind === 213 /* CallExpression */ || containingNodeKind === 176 /* Constructor */ || containingNodeKind === 214 /* NewExpression */ || containingNodeKind === 217 /* ParenthesizedExpression */ || containingNodeKind === 196 /* ParenthesizedType */;
166396
+ switch (containingNodeKind) {
166397
+ case 213 /* CallExpression */:
166398
+ case 214 /* NewExpression */: {
166399
+ const expression = contextToken.parent.expression;
166400
+ if (getLineAndCharacterOfPosition(sourceFile, expression.end).line !== getLineAndCharacterOfPosition(sourceFile, position).line) {
166401
+ return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
166402
+ }
166403
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
166404
+ }
166405
+ case 217 /* ParenthesizedExpression */:
166406
+ return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
166407
+ case 176 /* Constructor */:
166408
+ case 196 /* ParenthesizedType */:
166409
+ return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
166410
+ default:
166411
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166412
+ }
166304
166413
  case 23 /* OpenBracketToken */:
166305
- return containingNodeKind === 209 /* ArrayLiteralExpression */ || containingNodeKind === 181 /* IndexSignature */ || containingNodeKind === 167 /* ComputedPropertyName */;
166414
+ switch (containingNodeKind) {
166415
+ case 209 /* ArrayLiteralExpression */:
166416
+ case 181 /* IndexSignature */:
166417
+ case 189 /* TupleType */:
166418
+ case 167 /* ComputedPropertyName */:
166419
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
166420
+ default:
166421
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166422
+ }
166306
166423
  case 144 /* ModuleKeyword */:
166307
166424
  case 145 /* NamespaceKeyword */:
166308
166425
  case 102 /* ImportKeyword */:
166309
- return true;
166426
+ return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
166310
166427
  case 25 /* DotToken */:
166311
- return containingNodeKind === 267 /* ModuleDeclaration */;
166428
+ switch (containingNodeKind) {
166429
+ case 267 /* ModuleDeclaration */:
166430
+ return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
166431
+ default:
166432
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166433
+ }
166312
166434
  case 19 /* OpenBraceToken */:
166313
- return containingNodeKind === 263 /* ClassDeclaration */ || containingNodeKind === 210 /* ObjectLiteralExpression */;
166435
+ switch (containingNodeKind) {
166436
+ case 263 /* ClassDeclaration */:
166437
+ case 210 /* ObjectLiteralExpression */:
166438
+ return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
166439
+ default:
166440
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166441
+ }
166314
166442
  case 64 /* EqualsToken */:
166315
- return containingNodeKind === 260 /* VariableDeclaration */ || containingNodeKind === 226 /* BinaryExpression */;
166443
+ switch (containingNodeKind) {
166444
+ case 260 /* VariableDeclaration */:
166445
+ case 226 /* BinaryExpression */:
166446
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
166447
+ default:
166448
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166449
+ }
166316
166450
  case 16 /* TemplateHead */:
166317
- return containingNodeKind === 228 /* TemplateExpression */;
166451
+ return {
166452
+ defaultCommitCharacters: allCommitCharacters,
166453
+ isNewIdentifierLocation: containingNodeKind === 228 /* TemplateExpression */
166454
+ // `aa ${|
166455
+ };
166318
166456
  case 17 /* TemplateMiddle */:
166319
- return containingNodeKind === 239 /* TemplateSpan */;
166457
+ return {
166458
+ defaultCommitCharacters: allCommitCharacters,
166459
+ isNewIdentifierLocation: containingNodeKind === 239 /* TemplateSpan */
166460
+ // `aa ${10} dd ${|
166461
+ };
166320
166462
  case 134 /* AsyncKeyword */:
166321
- return containingNodeKind === 174 /* MethodDeclaration */ || containingNodeKind === 304 /* ShorthandPropertyAssignment */;
166463
+ return containingNodeKind === 174 /* MethodDeclaration */ || containingNodeKind === 304 /* ShorthandPropertyAssignment */ ? { defaultCommitCharacters: [], isNewIdentifierLocation: true } : { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166322
166464
  case 42 /* AsteriskToken */:
166323
- return containingNodeKind === 174 /* MethodDeclaration */;
166465
+ return containingNodeKind === 174 /* MethodDeclaration */ ? { defaultCommitCharacters: [], isNewIdentifierLocation: true } : { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166324
166466
  }
166325
166467
  if (isClassMemberCompletionKeyword(tokenKind)) {
166326
- return true;
166468
+ return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
166327
166469
  }
166328
166470
  }
166329
- return false;
166471
+ return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
166330
166472
  }
166331
166473
  function isInStringOrRegularExpressionOrTemplateLiteral(contextToken2) {
166332
166474
  return (isRegularExpressionLiteral(contextToken2) || isStringTextContainingNode(contextToken2)) && (rangeContainsPositionExclusive(contextToken2, position) || position === contextToken2.end && (!!contextToken2.isUnterminated || isRegularExpressionLiteral(contextToken2)));
@@ -179399,13 +179541,13 @@ function pasteEditsProvider(targetFile, pastedText, pasteLocations, copiedFrom,
179399
179541
  function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken, changes) {
179400
179542
  let actualPastedText;
179401
179543
  if (pastedText.length !== pasteLocations.length) {
179402
- actualPastedText = pastedText.length === 1 ? pastedText : [pastedText.join("\n")];
179544
+ actualPastedText = pastedText.length === 1 ? pastedText[0] : pastedText.join(getNewLineOrDefaultFromHost(formatContext.host, formatContext.options));
179403
179545
  }
179404
179546
  const statements = [];
179405
179547
  let newText = targetFile.text;
179406
179548
  for (let i = pasteLocations.length - 1; i >= 0; i--) {
179407
179549
  const { pos, end } = pasteLocations[i];
179408
- newText = actualPastedText ? newText.slice(0, pos) + actualPastedText[0] + newText.slice(end) : newText.slice(0, pos) + pastedText[i] + newText.slice(end);
179550
+ newText = actualPastedText ? newText.slice(0, pos) + actualPastedText + newText.slice(end) : newText.slice(0, pos) + pastedText[i] + newText.slice(end);
179409
179551
  }
179410
179552
  let importAdder;
179411
179553
  Debug.checkDefined(host.runWithTemporaryFileUpdate).call(host, targetFile.fileName, newText, (updatedProgram, originalProgram, updatedFile) => {
@@ -179436,22 +179578,37 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
179436
179578
  preferences,
179437
179579
  formatContext
179438
179580
  };
179439
- forEachChild(updatedFile, function cb(node) {
179440
- if (isIdentifier(node) && !(originalProgram == null ? void 0 : originalProgram.getTypeChecker().resolveName(
179441
- node.text,
179442
- node,
179443
- -1 /* All */,
179444
- /*excludeGlobals*/
179445
- false
179446
- ))) {
179447
- importAdder.addImportForUnresolvedIdentifier(
179448
- context,
179581
+ let offset = 0;
179582
+ pasteLocations.forEach((location, i) => {
179583
+ const oldTextLength = location.end - location.pos;
179584
+ const textToBePasted = actualPastedText ?? pastedText[i];
179585
+ const startPos = location.pos + offset;
179586
+ const endPos = startPos + textToBePasted.length;
179587
+ const range = { pos: startPos, end: endPos };
179588
+ offset += textToBePasted.length - oldTextLength;
179589
+ const enclosingNode = findAncestor(
179590
+ getTokenAtPosition(context.sourceFile, range.pos),
179591
+ (ancestorNode) => rangeContainsRange(ancestorNode, range)
179592
+ );
179593
+ if (!enclosingNode) return;
179594
+ forEachChild(enclosingNode, function importUnresolvedIdentifiers(node) {
179595
+ const isImportCandidate = isIdentifier(node) && rangeContainsPosition(range, node.getStart(updatedFile)) && !(updatedProgram == null ? void 0 : updatedProgram.getTypeChecker().resolveName(
179596
+ node.text,
179449
179597
  node,
179450
- /*useAutoImportProvider*/
179451
- true
179452
- );
179453
- }
179454
- node.forEachChild(cb);
179598
+ -1 /* All */,
179599
+ /*excludeGlobals*/
179600
+ false
179601
+ ));
179602
+ if (isImportCandidate) {
179603
+ return importAdder.addImportForUnresolvedIdentifier(
179604
+ context,
179605
+ node,
179606
+ /*useAutoImportProvider*/
179607
+ true
179608
+ );
179609
+ }
179610
+ node.forEachChild(importUnresolvedIdentifiers);
179611
+ });
179455
179612
  });
179456
179613
  }
179457
179614
  importAdder.writeFixes(changes, getQuotePreference(copiedFrom ? copiedFrom.file : targetFile, preferences));
@@ -179463,7 +179620,7 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
179463
179620
  changes.replaceRangeWithText(
179464
179621
  targetFile,
179465
179622
  { pos: paste.pos, end: paste.end },
179466
- actualPastedText ? actualPastedText[0] : pastedText[i]
179623
+ actualPastedText ?? pastedText[i]
179467
179624
  );
179468
179625
  });
179469
179626
  }
@@ -188987,7 +189144,7 @@ Dynamic files must always be opened with service's current directory or service
188987
189144
  if (cleanupAfter) {
188988
189145
  this.cleanupConfiguredProjects(
188989
189146
  configuredProjects,
188990
- new Set(proj.projectFileName)
189147
+ /* @__PURE__ */ new Set([proj.projectFileName])
188991
189148
  );
188992
189149
  this.printProjects();
188993
189150
  }
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.6.0-dev.20240819",
5
+ "version": "5.7.0-dev.20240820",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -117,5 +117,5 @@
117
117
  "node": "20.1.0",
118
118
  "npm": "8.19.4"
119
119
  },
120
- "gitHead": "2a8865e6ba95c9bdcdb9e2c9c08f10c5f5c75391"
120
+ "gitHead": "2192336dfee6f740b5828c8a4a8226e56626de1d"
121
121
  }