typescript 5.2.0-dev.20230720 → 5.2.0-dev.20230722

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.
@@ -4347,6 +4347,7 @@ declare namespace ts {
4347
4347
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
4348
4348
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
4349
4349
  readonly includeInlayEnumMemberValueHints?: boolean;
4350
+ readonly interactiveInlayHints?: boolean;
4350
4351
  readonly allowRenameOfImportPath?: boolean;
4351
4352
  readonly autoImportFileExcludePatterns?: string[];
4352
4353
  readonly organizeImportsIgnoreCase?: "auto" | boolean;
@@ -6413,12 +6414,17 @@ declare namespace ts {
6413
6414
  Enum = "Enum"
6414
6415
  }
6415
6416
  interface InlayHint {
6416
- text: string;
6417
+ text: string | InlayHintDisplayPart[];
6417
6418
  position: number;
6418
6419
  kind: InlayHintKind;
6419
6420
  whitespaceBefore?: boolean;
6420
6421
  whitespaceAfter?: boolean;
6421
6422
  }
6423
+ interface InlayHintDisplayPart {
6424
+ text: string;
6425
+ span?: TextSpan;
6426
+ file?: string;
6427
+ }
6422
6428
  interface TodoCommentDescriptor {
6423
6429
  text: string;
6424
6430
  priority: number;
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.2";
38
- version = `${versionMajorMinor}.0-dev.20230720`;
38
+ version = `${versionMajorMinor}.0-dev.20230722`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -19225,6 +19225,18 @@ ${lanes.join("\n")}
19225
19225
  function intrinsicTagNameToString(node) {
19226
19226
  return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
19227
19227
  }
19228
+ function isTypeUsableAsPropertyName(type) {
19229
+ return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
19230
+ }
19231
+ function getPropertyNameFromType(type) {
19232
+ if (type.flags & 8192 /* UniqueESSymbol */) {
19233
+ return type.escapedName;
19234
+ }
19235
+ if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
19236
+ return escapeLeadingUnderscores("" + type.value);
19237
+ }
19238
+ return Debug.fail();
19239
+ }
19228
19240
  var resolvingEmptyArray, externalHelpersModuleNameText, defaultMaximumTruncationLength, noTruncationMaximumTruncationLength, stringWriter, GetLiteralTextFlags, fullTripleSlashReferencePathRegEx, fullTripleSlashReferenceTypeReferenceDirectiveRegEx, fullTripleSlashLibReferenceRegEx, fullTripleSlashAMDReferencePathRegEx, fullTripleSlashAMDModuleRegEx, defaultLibReferenceRegEx, AssignmentKind, FunctionFlags, Associativity, OperatorPrecedence, templateSubstitutionRegExp, doubleQuoteEscapedCharsRegExp, singleQuoteEscapedCharsRegExp, backtickQuoteEscapedCharsRegExp, escapedCharsMap, nonAsciiCharacters, jsxDoubleQuoteEscapedCharsRegExp, jsxSingleQuoteEscapedCharsRegExp, jsxEscapedCharsMap, indentStrings, base64Digits, carriageReturnLineFeed, lineFeed, objectAllocator, objectAllocatorPatchers, localizedDiagnosticMessages, reservedCharacterPattern, wildcardCharCodes, commonPackageFolders, implicitExcludePathRegexPattern, filesMatcher, directoriesMatcher, excludeMatcher, wildcardMatchers, supportedTSExtensions, supportedTSExtensionsFlat, supportedTSExtensionsWithJson, supportedTSExtensionsForExtractExtension, supportedJSExtensions, supportedJSExtensionsFlat, allSupportedExtensions, allSupportedExtensionsWithJson, supportedDeclarationExtensions, supportedTSImplementationExtensions, extensionsNotSupportingExtensionlessResolution, ModuleSpecifierEnding, extensionsToRemove, emptyFileSystemEntries;
19229
19241
  var init_utilities = __esm({
19230
19242
  "src/compiler/utilities.ts"() {
@@ -33182,10 +33194,14 @@ ${lanes.join("\n")}
33182
33194
  case 124 /* ProtectedKeyword */:
33183
33195
  case 125 /* PublicKeyword */:
33184
33196
  case 148 /* ReadonlyKeyword */:
33197
+ const previousToken = token();
33185
33198
  nextToken();
33186
33199
  if (scanner2.hasPrecedingLineBreak()) {
33187
33200
  return false;
33188
33201
  }
33202
+ if (previousToken === 138 /* DeclareKeyword */ && token() === 156 /* TypeKeyword */) {
33203
+ return true;
33204
+ }
33189
33205
  continue;
33190
33206
  case 162 /* GlobalKeyword */:
33191
33207
  nextToken();
@@ -33550,14 +33566,14 @@ ${lanes.join("\n")}
33550
33566
  function parseObjectBindingPattern() {
33551
33567
  const pos = getNodePos();
33552
33568
  parseExpected(19 /* OpenBraceToken */);
33553
- const elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
33569
+ const elements = allowInAnd(() => parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement));
33554
33570
  parseExpected(20 /* CloseBraceToken */);
33555
33571
  return finishNode(factory2.createObjectBindingPattern(elements), pos);
33556
33572
  }
33557
33573
  function parseArrayBindingPattern() {
33558
33574
  const pos = getNodePos();
33559
33575
  parseExpected(23 /* OpenBracketToken */);
33560
- const elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
33576
+ const elements = allowInAnd(() => parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement));
33561
33577
  parseExpected(24 /* CloseBracketToken */);
33562
33578
  return finishNode(factory2.createArrayBindingPattern(elements), pos);
33563
33579
  }
@@ -34075,6 +34091,9 @@ ${lanes.join("\n")}
34075
34091
  }
34076
34092
  function parseTypeAliasDeclaration(pos, hasJSDoc, modifiers) {
34077
34093
  parseExpected(156 /* TypeKeyword */);
34094
+ if (scanner2.hasPrecedingLineBreak()) {
34095
+ parseErrorAtCurrentToken(Diagnostics.Line_break_not_permitted_here);
34096
+ }
34078
34097
  const name = parseIdentifier();
34079
34098
  const typeParameters = parseTypeParameters();
34080
34099
  parseExpected(64 /* EqualsToken */);
@@ -35858,7 +35877,7 @@ ${lanes.join("\n")}
35858
35877
  })(IncrementalParser || (IncrementalParser = {}));
35859
35878
  namedArgRegExCache = /* @__PURE__ */ new Map();
35860
35879
  tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
35861
- singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
35880
+ singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
35862
35881
  }
35863
35882
  });
35864
35883
 
@@ -45585,7 +45604,7 @@ ${lanes.join("\n")}
45585
45604
  return node ? getTypeFromTypeNode(node) : errorType;
45586
45605
  },
45587
45606
  getParameterType: getTypeAtPosition,
45588
- getParameterIdentifierNameAtPosition,
45607
+ getParameterIdentifierInfoAtPosition,
45589
45608
  getPromisedTypeOfPromise,
45590
45609
  getAwaitedType: (type) => getAwaitedType(type),
45591
45610
  getReturnTypeOfSignature,
@@ -54048,7 +54067,7 @@ ${lanes.join("\n")}
54048
54067
  false,
54049
54068
  definedInMethod && !definedInConstructor
54050
54069
  ));
54051
- if (symbol.valueDeclaration && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
54070
+ if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
54052
54071
  reportImplicitAny(symbol.valueDeclaration, anyType);
54053
54072
  return anyType;
54054
54073
  }
@@ -55327,9 +55346,6 @@ ${lanes.join("\n")}
55327
55346
  }
55328
55347
  return type;
55329
55348
  }
55330
- function isTypeUsableAsPropertyName(type) {
55331
- return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
55332
- }
55333
55349
  function isLateBindableName(node) {
55334
55350
  if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
55335
55351
  return false;
@@ -55350,15 +55366,6 @@ ${lanes.join("\n")}
55350
55366
  function isNonBindableDynamicName(node) {
55351
55367
  return isDynamicName(node) && !isLateBindableName(node);
55352
55368
  }
55353
- function getPropertyNameFromType(type) {
55354
- if (type.flags & 8192 /* UniqueESSymbol */) {
55355
- return type.escapedName;
55356
- }
55357
- if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
55358
- return escapeLeadingUnderscores("" + type.value);
55359
- }
55360
- return Debug.fail();
55361
- }
55362
55369
  function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
55363
55370
  Debug.assert(!!(getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol.");
55364
55371
  symbol.flags |= symbolFlags;
@@ -56005,20 +56012,17 @@ ${lanes.join("\n")}
56005
56012
  setStructuredTypeMembers(type, members2, callSignatures, constructSignatures, indexInfos2);
56006
56013
  return;
56007
56014
  }
56008
- let members = emptySymbols;
56015
+ let members = getExportsOfSymbol(symbol);
56009
56016
  let indexInfos;
56010
- if (symbol.exports) {
56011
- members = getExportsOfSymbol(symbol);
56012
- if (symbol === globalThisSymbol) {
56013
- const varsOnly = /* @__PURE__ */ new Map();
56014
- members.forEach((p) => {
56015
- var _a;
56016
- if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) == null ? void 0 : _a.length) && every(p.declarations, isAmbientModule))) {
56017
- varsOnly.set(p.escapedName, p);
56018
- }
56019
- });
56020
- members = varsOnly;
56021
- }
56017
+ if (symbol === globalThisSymbol) {
56018
+ const varsOnly = /* @__PURE__ */ new Map();
56019
+ members.forEach((p) => {
56020
+ var _a;
56021
+ if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) == null ? void 0 : _a.length) && every(p.declarations, isAmbientModule))) {
56022
+ varsOnly.set(p.escapedName, p);
56023
+ }
56024
+ });
56025
+ members = varsOnly;
56022
56026
  }
56023
56027
  let baseConstructorIndexInfo;
56024
56028
  setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
@@ -74530,7 +74534,7 @@ ${lanes.join("\n")}
74530
74534
  }
74531
74535
  return restParameter.escapedName;
74532
74536
  }
74533
- function getParameterIdentifierNameAtPosition(signature, pos) {
74537
+ function getParameterIdentifierInfoAtPosition(signature, pos) {
74534
74538
  var _a;
74535
74539
  if (((_a = signature.declaration) == null ? void 0 : _a.kind) === 324 /* JSDocFunctionType */) {
74536
74540
  return void 0;
@@ -74538,10 +74542,16 @@ ${lanes.join("\n")}
74538
74542
  const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
74539
74543
  if (pos < paramCount) {
74540
74544
  const param = signature.parameters[pos];
74541
- return isParameterDeclarationWithIdentifierName(param) ? [param.escapedName, false] : void 0;
74545
+ const paramIdent = getParameterDeclarationIdentifier(param);
74546
+ return paramIdent ? {
74547
+ parameter: paramIdent,
74548
+ parameterName: param.escapedName,
74549
+ isRestParameter: false
74550
+ } : void 0;
74542
74551
  }
74543
74552
  const restParameter = signature.parameters[paramCount] || unknownSymbol;
74544
- if (!isParameterDeclarationWithIdentifierName(restParameter)) {
74553
+ const restIdent = getParameterDeclarationIdentifier(restParameter);
74554
+ if (!restIdent) {
74545
74555
  return void 0;
74546
74556
  }
74547
74557
  const restType = getTypeOfSymbol(restParameter);
@@ -74550,18 +74560,19 @@ ${lanes.join("\n")}
74550
74560
  const index = pos - paramCount;
74551
74561
  const associatedName = associatedNames == null ? void 0 : associatedNames[index];
74552
74562
  const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
74553
- return associatedName ? [
74554
- getTupleElementLabel(associatedName),
74555
- isRestTupleElement
74556
- ] : void 0;
74563
+ if (associatedName) {
74564
+ Debug.assert(isIdentifier(associatedName.name));
74565
+ return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
74566
+ }
74567
+ return void 0;
74557
74568
  }
74558
74569
  if (pos === paramCount) {
74559
- return [restParameter.escapedName, true];
74570
+ return { parameter: restIdent, parameterName: restParameter.escapedName, isRestParameter: true };
74560
74571
  }
74561
74572
  return void 0;
74562
74573
  }
74563
- function isParameterDeclarationWithIdentifierName(symbol) {
74564
- return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name);
74574
+ function getParameterDeclarationIdentifier(symbol) {
74575
+ return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name) && symbol.valueDeclaration.name;
74565
74576
  }
74566
74577
  function isValidDeclarationForTupleLabel(d) {
74567
74578
  return d.kind === 202 /* NamedTupleMember */ || isParameter(d) && d.name && isIdentifier(d.name);
@@ -134415,8 +134426,8 @@ ${lanes.join("\n")}
134415
134426
  diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
134416
134427
  }
134417
134428
  }
134418
- const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
134419
- if (jsdocTypedefNode) {
134429
+ const jsdocTypedefNodes = ts_codefix_exports.getJSDocTypedefNodes(node);
134430
+ for (const jsdocTypedefNode of jsdocTypedefNodes) {
134420
134431
  diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
134421
134432
  }
134422
134433
  if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
@@ -148344,23 +148355,60 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148344
148355
  });
148345
148356
 
148346
148357
  // src/services/codefixes/convertTypedefToType.ts
148347
- function doChange12(changes, node, sourceFile) {
148348
- if (isJSDocTypedefTag(node)) {
148349
- fixSingleTypeDef(changes, node, sourceFile);
148350
- }
148351
- }
148352
- function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
148353
- if (!typeDefNode)
148358
+ function doChange12(changes, node, sourceFile, newLine, fixAll = false) {
148359
+ if (!isJSDocTypedefTag(node))
148354
148360
  return;
148355
- const declaration = createDeclaration(typeDefNode);
148361
+ const declaration = createDeclaration(node);
148356
148362
  if (!declaration)
148357
148363
  return;
148358
- const comment = typeDefNode.parent;
148359
- changes.replaceNode(
148360
- sourceFile,
148361
- comment,
148362
- declaration
148364
+ const commentNode = node.parent;
148365
+ const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
148366
+ let pos = commentNode.getStart();
148367
+ let prefix = "";
148368
+ if (!leftSibling && commentNode.comment) {
148369
+ pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
148370
+ prefix = `${newLine} */${newLine}`;
148371
+ }
148372
+ if (leftSibling) {
148373
+ if (fixAll && isJSDocTypedefTag(leftSibling)) {
148374
+ pos = node.getStart();
148375
+ prefix = "";
148376
+ } else {
148377
+ pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
148378
+ prefix = `${newLine} */${newLine}`;
148379
+ }
148380
+ }
148381
+ let end = commentNode.getEnd();
148382
+ let suffix = "";
148383
+ if (rightSibling) {
148384
+ if (fixAll && isJSDocTypedefTag(rightSibling)) {
148385
+ end = rightSibling.getStart();
148386
+ suffix = `${newLine}${newLine}`;
148387
+ } else {
148388
+ end = rightSibling.getStart();
148389
+ suffix = `${newLine}/**${newLine} * `;
148390
+ }
148391
+ }
148392
+ changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
148393
+ }
148394
+ function getLeftAndRightSiblings(typedefNode) {
148395
+ const commentNode = typedefNode.parent;
148396
+ const maxChildIndex = commentNode.getChildCount() - 1;
148397
+ const currentNodeIndex = commentNode.getChildren().findIndex(
148398
+ (n) => n.getStart() === typedefNode.getStart() && n.getEnd() === typedefNode.getEnd()
148363
148399
  );
148400
+ const leftSibling = currentNodeIndex > 0 ? commentNode.getChildAt(currentNodeIndex - 1) : void 0;
148401
+ const rightSibling = currentNodeIndex < maxChildIndex ? commentNode.getChildAt(currentNodeIndex + 1) : void 0;
148402
+ return { leftSibling, rightSibling };
148403
+ }
148404
+ function findEndOfTextBetween(jsDocComment, from, to) {
148405
+ const comment = jsDocComment.getText().substring(from - jsDocComment.getStart(), to - jsDocComment.getStart());
148406
+ for (let i = comment.length; i > 0; i--) {
148407
+ if (!/[*\/\s]/g.test(comment.substring(i - 1, i))) {
148408
+ return from + i;
148409
+ }
148410
+ }
148411
+ return to;
148364
148412
  }
148365
148413
  function createDeclaration(tag) {
148366
148414
  var _a;
@@ -148381,7 +148429,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148381
148429
  const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
148382
148430
  if (!some(propertySignatures))
148383
148431
  return;
148384
- const interfaceDeclaration = factory.createInterfaceDeclaration(
148432
+ return factory.createInterfaceDeclaration(
148385
148433
  /*modifiers*/
148386
148434
  void 0,
148387
148435
  typeName,
@@ -148391,13 +148439,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148391
148439
  void 0,
148392
148440
  propertySignatures
148393
148441
  );
148394
- return interfaceDeclaration;
148395
148442
  }
148396
148443
  function createTypeAliasForTypeExpression(typeName, typeExpression) {
148397
148444
  const typeReference = getSynthesizedDeepClone(typeExpression.type);
148398
148445
  if (!typeReference)
148399
148446
  return;
148400
- const declaration = factory.createTypeAliasDeclaration(
148447
+ return factory.createTypeAliasDeclaration(
148401
148448
  /*modifiers*/
148402
148449
  void 0,
148403
148450
  factory.createIdentifier(typeName),
@@ -148405,7 +148452,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148405
148452
  void 0,
148406
148453
  typeReference
148407
148454
  );
148408
- return declaration;
148409
148455
  }
148410
148456
  function createSignatureFromTypeLiteral(typeLiteral) {
148411
148457
  const propertyTags = typeLiteral.jsDocPropertyTags;
@@ -148425,30 +148471,28 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148425
148471
  }
148426
148472
  if (typeReference && name) {
148427
148473
  const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
148428
- const prop = factory.createPropertySignature(
148474
+ return factory.createPropertySignature(
148429
148475
  /*modifiers*/
148430
148476
  void 0,
148431
148477
  name,
148432
148478
  questionToken,
148433
148479
  typeReference
148434
148480
  );
148435
- return prop;
148436
148481
  }
148437
148482
  };
148438
- const props = mapDefined(propertyTags, getSignature);
148439
- return props;
148483
+ return mapDefined(propertyTags, getSignature);
148440
148484
  }
148441
148485
  function getPropertyName(tag) {
148442
148486
  return tag.name.kind === 80 /* Identifier */ ? tag.name.text : tag.name.right.text;
148443
148487
  }
148444
- function getJSDocTypedefNode(node) {
148488
+ function getJSDocTypedefNodes(node) {
148445
148489
  if (hasJSDocNodes(node)) {
148446
- return forEach(node.jsDoc, (node2) => {
148490
+ return flatMap(node.jsDoc, (doc) => {
148447
148491
  var _a;
148448
- return (_a = node2.tags) == null ? void 0 : _a.find(isJSDocTypedefTag);
148492
+ return (_a = doc.tags) == null ? void 0 : _a.filter((tag) => isJSDocTypedefTag(tag));
148449
148493
  });
148450
148494
  }
148451
- return void 0;
148495
+ return [];
148452
148496
  }
148453
148497
  var fixId14, errorCodes15;
148454
148498
  var init_convertTypedefToType = __esm({
@@ -148462,13 +148506,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148462
148506
  fixIds: [fixId14],
148463
148507
  errorCodes: errorCodes15,
148464
148508
  getCodeActions(context) {
148509
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
148465
148510
  const node = getTokenAtPosition(
148466
148511
  context.sourceFile,
148467
148512
  context.span.start
148468
148513
  );
148469
148514
  if (!node)
148470
148515
  return;
148471
- const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile));
148516
+ const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile, newLineCharacter));
148472
148517
  if (changes.length > 0) {
148473
148518
  return [
148474
148519
  createCodeFixAction(
@@ -148481,11 +148526,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148481
148526
  ];
148482
148527
  }
148483
148528
  },
148484
- getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
148485
- const node = getTokenAtPosition(diag2.file, diag2.start);
148486
- if (node)
148487
- doChange12(changes, node, diag2.file);
148488
- })
148529
+ getAllCodeActions: (context) => codeFixAll(
148530
+ context,
148531
+ errorCodes15,
148532
+ (changes, diag2) => {
148533
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
148534
+ const node = getTokenAtPosition(diag2.file, diag2.start);
148535
+ const fixAll = true;
148536
+ if (node)
148537
+ doChange12(changes, node, diag2.file, newLineCharacter, fixAll);
148538
+ }
148539
+ )
148489
148540
  });
148490
148541
  }
148491
148542
  });
@@ -150760,6 +150811,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
150760
150811
  if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
150761
150812
  return void 0;
150762
150813
  const pos = declaration.parent.arguments.indexOf(declaration);
150814
+ if (pos === -1)
150815
+ return void 0;
150763
150816
  const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
150764
150817
  if (!type)
150765
150818
  return void 0;
@@ -154185,15 +154238,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
154185
154238
  }
154186
154239
  function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional = 3 /* All */, isAmbient = false) {
154187
154240
  const declarations = symbol.getDeclarations();
154188
- const declaration = declarations == null ? void 0 : declarations[0];
154241
+ const declaration = firstOrUndefined(declarations);
154189
154242
  const checker = context.program.getTypeChecker();
154190
154243
  const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
154191
154244
  const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */;
154192
- const declarationName = getSynthesizedDeepClone(
154193
- getNameOfDeclaration(declaration),
154194
- /*includeTrivia*/
154195
- false
154196
- );
154245
+ const declarationName = createDeclarationName(symbol, declaration);
154197
154246
  const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */;
154198
154247
  let modifierFlags = effectiveModifierFlags & 32 /* Static */;
154199
154248
  modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */;
@@ -154344,6 +154393,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
154344
154393
  false
154345
154394
  );
154346
154395
  }
154396
+ function createDeclarationName(symbol2, declaration2) {
154397
+ if (getCheckFlags(symbol2) & 262144 /* Mapped */) {
154398
+ const nameType = symbol2.links.nameType;
154399
+ if (nameType && isTypeUsableAsPropertyName(nameType)) {
154400
+ return factory.createIdentifier(unescapeLeadingUnderscores(getPropertyNameFromType(nameType)));
154401
+ }
154402
+ }
154403
+ return getSynthesizedDeepClone(
154404
+ getNameOfDeclaration(declaration2),
154405
+ /*includeTrivia*/
154406
+ false
154407
+ );
154408
+ }
154347
154409
  }
154348
154410
  function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
154349
154411
  const program = context.program;
@@ -155999,7 +156061,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
155999
156061
  getFixes: () => getFixes,
156000
156062
  getImportCompletionAction: () => getImportCompletionAction,
156001
156063
  getImportKind: () => getImportKind,
156002
- getJSDocTypedefNode: () => getJSDocTypedefNode,
156064
+ getJSDocTypedefNodes: () => getJSDocTypedefNodes,
156003
156065
  getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
156004
156066
  getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
156005
156067
  getSupportedErrorCodes: () => getSupportedErrorCodes,
@@ -163875,6 +163937,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163875
163937
  function shouldShowLiteralParameterNameHintsOnly(preferences) {
163876
163938
  return preferences.includeInlayParameterNameHints === "literals";
163877
163939
  }
163940
+ function shouldUseInteractiveInlayHints(preferences) {
163941
+ return preferences.interactiveInlayHints === true;
163942
+ }
163878
163943
  function provideInlayHints(context) {
163879
163944
  const { file, program, span, cancellationToken, preferences } = context;
163880
163945
  const sourceFileText = file.text;
@@ -163925,9 +163990,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163925
163990
  function isSignatureSupportingReturnAnnotation(node) {
163926
163991
  return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
163927
163992
  }
163928
- function addParameterHints(text, position, isFirstVariadicArgument) {
163993
+ function addParameterHints(text, parameter, position, isFirstVariadicArgument, sourceFile) {
163994
+ let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
163995
+ if (shouldUseInteractiveInlayHints(preferences)) {
163996
+ hintText = [getNodeDisplayPart(hintText, parameter, sourceFile), { text: ":" }];
163997
+ } else {
163998
+ hintText += ":";
163999
+ }
163929
164000
  result.push({
163930
- text: `${isFirstVariadicArgument ? "..." : ""}${truncation(text, maxHintsLength)}:`,
164001
+ text: hintText,
163931
164002
  position,
163932
164003
  kind: "Parameter" /* Parameter */,
163933
164004
  whitespaceAfter: true
@@ -163935,7 +164006,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163935
164006
  }
163936
164007
  function addTypeHints(text, position) {
163937
164008
  result.push({
163938
- text: `: ${truncation(text, maxHintsLength)}`,
164009
+ text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
163939
164010
  position,
163940
164011
  kind: "Type" /* Type */,
163941
164012
  whitespaceBefore: true
@@ -163943,7 +164014,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163943
164014
  }
163944
164015
  function addEnumMemberValueHints(text, position) {
163945
164016
  result.push({
163946
- text: `= ${truncation(text, maxHintsLength)}`,
164017
+ text: `= ${text}`,
163947
164018
  position,
163948
164019
  kind: "Enum" /* Enum */,
163949
164020
  whitespaceBefore: true
@@ -163993,6 +164064,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163993
164064
  return;
163994
164065
  }
163995
164066
  let signatureParamPos = 0;
164067
+ const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
163996
164068
  for (const originalArg of args) {
163997
164069
  const arg = skipParentheses(originalArg);
163998
164070
  if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
@@ -164013,10 +164085,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164013
164085
  }
164014
164086
  }
164015
164087
  }
164016
- const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
164088
+ const identifierInfo = checker.getParameterIdentifierInfoAtPosition(signature, signatureParamPos);
164017
164089
  signatureParamPos = signatureParamPos + (spreadArgs || 1);
164018
- if (identifierNameInfo) {
164019
- const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
164090
+ if (identifierInfo) {
164091
+ const { parameter, parameterName, isRestParameter: isFirstVariadicArgument } = identifierInfo;
164020
164092
  const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
164021
164093
  if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
164022
164094
  continue;
@@ -164025,7 +164097,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164025
164097
  if (leadingCommentsContainsParameterName(arg, name)) {
164026
164098
  continue;
164027
164099
  }
164028
- addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument);
164100
+ addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
164029
164101
  }
164030
164102
  }
164031
164103
  }
@@ -164131,12 +164203,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164131
164203
  }
164132
164204
  return printTypeInSingleLine(signatureParamType);
164133
164205
  }
164134
- function truncation(text, maxLength2) {
164135
- if (text.length > maxLength2) {
164136
- return text.substr(0, maxLength2 - "...".length) + "...";
164137
- }
164138
- return text;
164139
- }
164140
164206
  function printTypeInSingleLine(type) {
164141
164207
  const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
164142
164208
  const printer = createPrinterWithRemoveComments();
@@ -164167,13 +164233,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164167
164233
  }
164168
164234
  return true;
164169
164235
  }
164236
+ function getNodeDisplayPart(text, node, sourceFile) {
164237
+ return {
164238
+ text,
164239
+ span: createTextSpanFromNode(node, sourceFile),
164240
+ file: sourceFile.fileName
164241
+ };
164242
+ }
164170
164243
  }
164171
- var maxHintsLength, leadingParameterNameCommentRegexFactory;
164244
+ var maxTypeHintLength, leadingParameterNameCommentRegexFactory;
164172
164245
  var init_inlayHints = __esm({
164173
164246
  "src/services/inlayHints.ts"() {
164174
164247
  "use strict";
164175
164248
  init_ts4();
164176
- maxHintsLength = 30;
164249
+ maxTypeHintLength = 30;
164177
164250
  leadingParameterNameCommentRegexFactory = (name) => {
164178
164251
  return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
164179
164252
  };
@@ -166675,7 +166748,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166675
166748
  }
166676
166749
  return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
166677
166750
  }
166678
- function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
166751
+ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
166679
166752
  var _a;
166680
166753
  const displayParts = [];
166681
166754
  let documentation = [];
@@ -166684,7 +166757,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166684
166757
  let symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
166685
166758
  let hasAddedSymbolInfo = false;
166686
166759
  const isThisExpression = location.kind === 110 /* ThisKeyword */ && isInExpressionContext(location) || isThisInTypeQuery(location);
166687
- let type;
166688
166760
  let documentationFromAlias;
166689
166761
  let tagsFromAlias;
166690
166762
  let hasMultipleSignatures = false;
@@ -166713,7 +166785,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166713
166785
  }
166714
166786
  }
166715
166787
  let signature;
166716
- type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
166788
+ type ?? (type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location));
166717
166789
  if (location.parent && location.parent.kind === 211 /* PropertyAccessExpression */) {
166718
166790
  const right = location.parent.name;
166719
166791
  if (right === location || right && right.getFullWidth() === 0) {
@@ -166928,12 +167000,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166928
167000
  if (declarationName && !hasAddedSymbolInfo) {
166929
167001
  const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
166930
167002
  const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
166931
- const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(
167003
+ const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
166932
167004
  typeChecker,
166933
167005
  resolvedSymbol,
166934
167006
  getSourceFileOfNode(resolvedNode),
166935
167007
  resolvedNode,
166936
167008
  declarationName,
167009
+ type,
166937
167010
  semanticMeaning,
166938
167011
  shouldUseAliasName ? symbol : resolvedSymbol
166939
167012
  );
@@ -167188,6 +167261,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167188
167261
  addRange(displayParts, typeParameterParts);
167189
167262
  }
167190
167263
  }
167264
+ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
167265
+ return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
167266
+ typeChecker,
167267
+ symbol,
167268
+ sourceFile,
167269
+ enclosingDeclaration,
167270
+ location,
167271
+ /*type*/
167272
+ void 0,
167273
+ semanticMeaning,
167274
+ alias
167275
+ );
167276
+ }
167191
167277
  function isLocalVariableOrFunction(symbol) {
167192
167278
  if (symbol.parent) {
167193
167279
  return false;
@@ -172503,6 +172589,7 @@ ${options.prefix}` : "\n" : options.prefix
172503
172589
  getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
172504
172590
  getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
172505
172591
  getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
172592
+ getPropertyNameFromType: () => getPropertyNameFromType,
172506
172593
  getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
172507
172594
  getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
172508
172595
  getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
@@ -173335,6 +173422,7 @@ ${options.prefix}` : "\n" : options.prefix
173335
173422
  isTypeQueryNode: () => isTypeQueryNode,
173336
173423
  isTypeReferenceNode: () => isTypeReferenceNode,
173337
173424
  isTypeReferenceType: () => isTypeReferenceType,
173425
+ isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
173338
173426
  isUMDExportSymbol: () => isUMDExportSymbol,
173339
173427
  isUnaryExpression: () => isUnaryExpression,
173340
173428
  isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,