typescript 5.2.0-dev.20230720 → 5.2.0-dev.20230721

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.
@@ -2124,12 +2124,16 @@ declare namespace ts {
2124
2124
  arguments: InlayHintsRequestArgs;
2125
2125
  }
2126
2126
  interface InlayHintItem {
2127
- text: string;
2127
+ text: string | InlayHintItemDisplayPart[];
2128
2128
  position: Location;
2129
2129
  kind: InlayHintKind;
2130
2130
  whitespaceBefore?: boolean;
2131
2131
  whitespaceAfter?: boolean;
2132
2132
  }
2133
+ interface InlayHintItemDisplayPart {
2134
+ text: string;
2135
+ span?: FileSpan;
2136
+ }
2133
2137
  interface InlayHintsResponse extends Response {
2134
2138
  body?: InlayHintItem[];
2135
2139
  }
@@ -2832,6 +2836,7 @@ declare namespace ts {
2832
2836
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
2833
2837
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
2834
2838
  readonly includeInlayEnumMemberValueHints?: boolean;
2839
+ readonly interactiveInlayHints?: boolean;
2835
2840
  readonly autoImportFileExcludePatterns?: string[];
2836
2841
  /**
2837
2842
  * Indicates whether imports should be organized in a case-insensitive manner.
@@ -8400,6 +8405,7 @@ declare namespace ts {
8400
8405
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
8401
8406
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
8402
8407
  readonly includeInlayEnumMemberValueHints?: boolean;
8408
+ readonly interactiveInlayHints?: boolean;
8403
8409
  readonly allowRenameOfImportPath?: boolean;
8404
8410
  readonly autoImportFileExcludePatterns?: string[];
8405
8411
  readonly organizeImportsIgnoreCase?: "auto" | boolean;
@@ -10382,12 +10388,17 @@ declare namespace ts {
10382
10388
  Enum = "Enum"
10383
10389
  }
10384
10390
  interface InlayHint {
10385
- text: string;
10391
+ text: string | InlayHintDisplayPart[];
10386
10392
  position: number;
10387
10393
  kind: InlayHintKind;
10388
10394
  whitespaceBefore?: boolean;
10389
10395
  whitespaceAfter?: boolean;
10390
10396
  }
10397
+ interface InlayHintDisplayPart {
10398
+ text: string;
10399
+ span?: TextSpan;
10400
+ file?: string;
10401
+ }
10391
10402
  interface TodoCommentDescriptor {
10392
10403
  text: string;
10393
10404
  priority: number;
@@ -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.20230721`;
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 */);
@@ -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);
@@ -154170,15 +154181,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
154170
154181
  }
154171
154182
  function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional = 3 /* All */, isAmbient = false) {
154172
154183
  const declarations = symbol.getDeclarations();
154173
- const declaration = declarations == null ? void 0 : declarations[0];
154184
+ const declaration = firstOrUndefined(declarations);
154174
154185
  const checker = context.program.getTypeChecker();
154175
154186
  const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
154176
154187
  const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */;
154177
- const declarationName = getSynthesizedDeepClone(
154178
- getNameOfDeclaration(declaration),
154179
- /*includeTrivia*/
154180
- false
154181
- );
154188
+ const declarationName = createDeclarationName(symbol, declaration);
154182
154189
  const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */;
154183
154190
  let modifierFlags = effectiveModifierFlags & 32 /* Static */;
154184
154191
  modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */;
@@ -154329,6 +154336,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
154329
154336
  false
154330
154337
  );
154331
154338
  }
154339
+ function createDeclarationName(symbol2, declaration2) {
154340
+ if (getCheckFlags(symbol2) & 262144 /* Mapped */) {
154341
+ const nameType = symbol2.links.nameType;
154342
+ if (nameType && isTypeUsableAsPropertyName(nameType)) {
154343
+ return factory.createIdentifier(unescapeLeadingUnderscores(getPropertyNameFromType(nameType)));
154344
+ }
154345
+ }
154346
+ return getSynthesizedDeepClone(
154347
+ getNameOfDeclaration(declaration2),
154348
+ /*includeTrivia*/
154349
+ false
154350
+ );
154351
+ }
154332
154352
  }
154333
154353
  function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
154334
154354
  const program = context.program;
@@ -163860,6 +163880,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163860
163880
  function shouldShowLiteralParameterNameHintsOnly(preferences) {
163861
163881
  return preferences.includeInlayParameterNameHints === "literals";
163862
163882
  }
163883
+ function shouldUseInteractiveInlayHints(preferences) {
163884
+ return preferences.interactiveInlayHints === true;
163885
+ }
163863
163886
  function provideInlayHints(context) {
163864
163887
  const { file, program, span, cancellationToken, preferences } = context;
163865
163888
  const sourceFileText = file.text;
@@ -163910,9 +163933,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163910
163933
  function isSignatureSupportingReturnAnnotation(node) {
163911
163934
  return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
163912
163935
  }
163913
- function addParameterHints(text, position, isFirstVariadicArgument) {
163936
+ function addParameterHints(text, parameter, position, isFirstVariadicArgument, sourceFile) {
163937
+ let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
163938
+ if (shouldUseInteractiveInlayHints(preferences)) {
163939
+ hintText = [getNodeDisplayPart(hintText, parameter, sourceFile), { text: ":" }];
163940
+ } else {
163941
+ hintText += ":";
163942
+ }
163914
163943
  result.push({
163915
- text: `${isFirstVariadicArgument ? "..." : ""}${truncation(text, maxHintsLength)}:`,
163944
+ text: hintText,
163916
163945
  position,
163917
163946
  kind: "Parameter" /* Parameter */,
163918
163947
  whitespaceAfter: true
@@ -163920,7 +163949,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163920
163949
  }
163921
163950
  function addTypeHints(text, position) {
163922
163951
  result.push({
163923
- text: `: ${truncation(text, maxHintsLength)}`,
163952
+ text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
163924
163953
  position,
163925
163954
  kind: "Type" /* Type */,
163926
163955
  whitespaceBefore: true
@@ -163928,7 +163957,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163928
163957
  }
163929
163958
  function addEnumMemberValueHints(text, position) {
163930
163959
  result.push({
163931
- text: `= ${truncation(text, maxHintsLength)}`,
163960
+ text: `= ${text}`,
163932
163961
  position,
163933
163962
  kind: "Enum" /* Enum */,
163934
163963
  whitespaceBefore: true
@@ -163978,6 +164007,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163978
164007
  return;
163979
164008
  }
163980
164009
  let signatureParamPos = 0;
164010
+ const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
163981
164011
  for (const originalArg of args) {
163982
164012
  const arg = skipParentheses(originalArg);
163983
164013
  if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
@@ -163998,10 +164028,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163998
164028
  }
163999
164029
  }
164000
164030
  }
164001
- const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
164031
+ const identifierInfo = checker.getParameterIdentifierInfoAtPosition(signature, signatureParamPos);
164002
164032
  signatureParamPos = signatureParamPos + (spreadArgs || 1);
164003
- if (identifierNameInfo) {
164004
- const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
164033
+ if (identifierInfo) {
164034
+ const { parameter, parameterName, isRestParameter: isFirstVariadicArgument } = identifierInfo;
164005
164035
  const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
164006
164036
  if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
164007
164037
  continue;
@@ -164010,7 +164040,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164010
164040
  if (leadingCommentsContainsParameterName(arg, name)) {
164011
164041
  continue;
164012
164042
  }
164013
- addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument);
164043
+ addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
164014
164044
  }
164015
164045
  }
164016
164046
  }
@@ -164116,12 +164146,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164116
164146
  }
164117
164147
  return printTypeInSingleLine(signatureParamType);
164118
164148
  }
164119
- function truncation(text, maxLength2) {
164120
- if (text.length > maxLength2) {
164121
- return text.substr(0, maxLength2 - "...".length) + "...";
164122
- }
164123
- return text;
164124
- }
164125
164149
  function printTypeInSingleLine(type) {
164126
164150
  const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
164127
164151
  const printer = createPrinterWithRemoveComments();
@@ -164152,13 +164176,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164152
164176
  }
164153
164177
  return true;
164154
164178
  }
164179
+ function getNodeDisplayPart(text, node, sourceFile) {
164180
+ return {
164181
+ text,
164182
+ span: createTextSpanFromNode(node, sourceFile),
164183
+ file: sourceFile.fileName
164184
+ };
164185
+ }
164155
164186
  }
164156
- var maxHintsLength, leadingParameterNameCommentRegexFactory;
164187
+ var maxTypeHintLength, leadingParameterNameCommentRegexFactory;
164157
164188
  var init_inlayHints = __esm({
164158
164189
  "src/services/inlayHints.ts"() {
164159
164190
  "use strict";
164160
164191
  init_ts4();
164161
- maxHintsLength = 30;
164192
+ maxTypeHintLength = 30;
164162
164193
  leadingParameterNameCommentRegexFactory = (name) => {
164163
164194
  return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
164164
164195
  };
@@ -166660,7 +166691,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166660
166691
  }
166661
166692
  return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
166662
166693
  }
166663
- function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
166694
+ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
166664
166695
  var _a;
166665
166696
  const displayParts = [];
166666
166697
  let documentation = [];
@@ -166669,7 +166700,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166669
166700
  let symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
166670
166701
  let hasAddedSymbolInfo = false;
166671
166702
  const isThisExpression = location.kind === 110 /* ThisKeyword */ && isInExpressionContext(location) || isThisInTypeQuery(location);
166672
- let type;
166673
166703
  let documentationFromAlias;
166674
166704
  let tagsFromAlias;
166675
166705
  let hasMultipleSignatures = false;
@@ -166698,7 +166728,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166698
166728
  }
166699
166729
  }
166700
166730
  let signature;
166701
- type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
166731
+ type ?? (type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location));
166702
166732
  if (location.parent && location.parent.kind === 211 /* PropertyAccessExpression */) {
166703
166733
  const right = location.parent.name;
166704
166734
  if (right === location || right && right.getFullWidth() === 0) {
@@ -166913,12 +166943,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
166913
166943
  if (declarationName && !hasAddedSymbolInfo) {
166914
166944
  const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
166915
166945
  const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
166916
- const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(
166946
+ const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
166917
166947
  typeChecker,
166918
166948
  resolvedSymbol,
166919
166949
  getSourceFileOfNode(resolvedNode),
166920
166950
  resolvedNode,
166921
166951
  declarationName,
166952
+ type,
166922
166953
  semanticMeaning,
166923
166954
  shouldUseAliasName ? symbol : resolvedSymbol
166924
166955
  );
@@ -167173,6 +167204,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167173
167204
  addRange(displayParts, typeParameterParts);
167174
167205
  }
167175
167206
  }
167207
+ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
167208
+ return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
167209
+ typeChecker,
167210
+ symbol,
167211
+ sourceFile,
167212
+ enclosingDeclaration,
167213
+ location,
167214
+ /*type*/
167215
+ void 0,
167216
+ semanticMeaning,
167217
+ alias
167218
+ );
167219
+ }
167176
167220
  function isLocalVariableOrFunction(symbol) {
167177
167221
  if (symbol.parent) {
167178
167222
  return false;
@@ -180846,10 +180890,22 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
180846
180890
  const { file, project } = this.getFileAndProject(args);
180847
180891
  const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
180848
180892
  const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));
180849
- return hints.map((hint) => ({
180850
- ...hint,
180851
- position: scriptInfo.positionToLineOffset(hint.position)
180852
- }));
180893
+ return hints.map((hint) => {
180894
+ const { text, position } = hint;
180895
+ const hintText = typeof text === "string" ? text : text.map(({ text: text2, span, file: file2 }) => ({
180896
+ text: text2,
180897
+ span: span && {
180898
+ start: scriptInfo.positionToLineOffset(span.start),
180899
+ end: scriptInfo.positionToLineOffset(span.start + span.length),
180900
+ file: file2
180901
+ }
180902
+ }));
180903
+ return {
180904
+ ...hint,
180905
+ position: scriptInfo.positionToLineOffset(position),
180906
+ text: hintText
180907
+ };
180908
+ });
180853
180909
  }
180854
180910
  setCompilerOptionsForInferredProjects(args) {
180855
180911
  this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
@@ -183882,6 +183938,7 @@ ${e.message}`;
183882
183938
  getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
183883
183939
  getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
183884
183940
  getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
183941
+ getPropertyNameFromType: () => getPropertyNameFromType,
183885
183942
  getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
183886
183943
  getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
183887
183944
  getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
@@ -184714,6 +184771,7 @@ ${e.message}`;
184714
184771
  isTypeQueryNode: () => isTypeQueryNode,
184715
184772
  isTypeReferenceNode: () => isTypeReferenceNode,
184716
184773
  isTypeReferenceType: () => isTypeReferenceType,
184774
+ isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
184717
184775
  isUMDExportSymbol: () => isUMDExportSymbol,
184718
184776
  isUnaryExpression: () => isUnaryExpression,
184719
184777
  isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
@@ -186285,6 +186343,7 @@ ${e.message}`;
186285
186343
  getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
186286
186344
  getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
186287
186345
  getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
186346
+ getPropertyNameFromType: () => getPropertyNameFromType,
186288
186347
  getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
186289
186348
  getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
186290
186349
  getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
@@ -187117,6 +187176,7 @@ ${e.message}`;
187117
187176
  isTypeQueryNode: () => isTypeQueryNode,
187118
187177
  isTypeReferenceNode: () => isTypeReferenceNode,
187119
187178
  isTypeReferenceType: () => isTypeReferenceType,
187179
+ isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
187120
187180
  isUMDExportSymbol: () => isUMDExportSymbol,
187121
187181
  isUnaryExpression: () => isUnaryExpression,
187122
187182
  isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
@@ -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;