typescript 5.2.0-dev.20230719 → 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.
- package/lib/tsc.js +61 -46
- package/lib/tsserver.js +141 -75
- package/lib/tsserverlibrary.d.ts +13 -2
- package/lib/tsserverlibrary.js +140 -76
- package/lib/typescript.d.ts +7 -1
- package/lib/typescript.js +122 -72
- package/lib/typingsInstaller.js +10 -3
- package/package.json +2 -2
package/lib/tsserverlibrary.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.
|
|
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
|
-
|
|
45607
|
+
getParameterIdentifierInfoAtPosition,
|
|
45589
45608
|
getPromisedTypeOfPromise,
|
|
45590
45609
|
getAwaitedType: (type) => getAwaitedType(type),
|
|
45591
45610
|
getReturnTypeOfSignature,
|
|
@@ -47026,7 +47045,7 @@ ${lanes.join("\n")}
|
|
|
47026
47045
|
if (name === "const" && isConstAssertion(location)) {
|
|
47027
47046
|
return void 0;
|
|
47028
47047
|
}
|
|
47029
|
-
if (
|
|
47048
|
+
if (isModuleOrEnumDeclaration(location) && lastLocation && location.name === lastLocation) {
|
|
47030
47049
|
lastLocation = location;
|
|
47031
47050
|
location = location.parent;
|
|
47032
47051
|
}
|
|
@@ -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;
|
|
@@ -55408,6 +55415,7 @@ ${lanes.join("\n")}
|
|
|
55408
55415
|
return links.resolvedSymbol;
|
|
55409
55416
|
}
|
|
55410
55417
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
55418
|
+
var _a, _b, _c;
|
|
55411
55419
|
const links = getSymbolLinks(symbol);
|
|
55412
55420
|
if (!links[resolutionKind]) {
|
|
55413
55421
|
const isStatic2 = resolutionKind === "resolvedExports" /* resolvedExports */;
|
|
@@ -55426,7 +55434,7 @@ ${lanes.join("\n")}
|
|
|
55426
55434
|
}
|
|
55427
55435
|
}
|
|
55428
55436
|
}
|
|
55429
|
-
const assignments = symbol.assignmentDeclarationMembers;
|
|
55437
|
+
const assignments = (((_a = symbol.valueDeclaration) == null ? void 0 : _a.kind) === 219 /* ArrowFunction */ || ((_b = symbol.valueDeclaration) == null ? void 0 : _b.kind) === 218 /* FunctionExpression */) && ((_c = getSymbolOfNode(symbol.valueDeclaration.parent)) == null ? void 0 : _c.assignmentDeclarationMembers) || symbol.assignmentDeclarationMembers;
|
|
55430
55438
|
if (assignments) {
|
|
55431
55439
|
const decls = arrayFrom(assignments.values());
|
|
55432
55440
|
for (const member of decls) {
|
|
@@ -56004,20 +56012,17 @@ ${lanes.join("\n")}
|
|
|
56004
56012
|
setStructuredTypeMembers(type, members2, callSignatures, constructSignatures, indexInfos2);
|
|
56005
56013
|
return;
|
|
56006
56014
|
}
|
|
56007
|
-
let members =
|
|
56015
|
+
let members = getExportsOfSymbol(symbol);
|
|
56008
56016
|
let indexInfos;
|
|
56009
|
-
if (symbol
|
|
56010
|
-
|
|
56011
|
-
|
|
56012
|
-
|
|
56013
|
-
|
|
56014
|
-
|
|
56015
|
-
|
|
56016
|
-
|
|
56017
|
-
|
|
56018
|
-
});
|
|
56019
|
-
members = varsOnly;
|
|
56020
|
-
}
|
|
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;
|
|
56021
56026
|
}
|
|
56022
56027
|
let baseConstructorIndexInfo;
|
|
56023
56028
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
|
@@ -68110,12 +68115,15 @@ ${lanes.join("\n")}
|
|
|
68110
68115
|
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
68111
68116
|
}
|
|
68112
68117
|
const target = getReferenceCandidate(expr.right);
|
|
68113
|
-
|
|
68114
|
-
|
|
68115
|
-
if (
|
|
68118
|
+
if (containsMissingType(type) && isAccessExpression(reference) && isMatchingReference(reference.expression, target)) {
|
|
68119
|
+
const leftType = getTypeOfExpression(expr.left);
|
|
68120
|
+
if (isTypeUsableAsPropertyName(leftType) && getAccessedPropertyName(reference) === getPropertyNameFromType(leftType)) {
|
|
68116
68121
|
return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */);
|
|
68117
68122
|
}
|
|
68118
|
-
|
|
68123
|
+
}
|
|
68124
|
+
if (isMatchingReference(reference, target)) {
|
|
68125
|
+
const leftType = getTypeOfExpression(expr.left);
|
|
68126
|
+
if (isTypeUsableAsPropertyName(leftType)) {
|
|
68119
68127
|
return narrowTypeByInKeyword(type, leftType, assumeTrue);
|
|
68120
68128
|
}
|
|
68121
68129
|
}
|
|
@@ -74526,7 +74534,7 @@ ${lanes.join("\n")}
|
|
|
74526
74534
|
}
|
|
74527
74535
|
return restParameter.escapedName;
|
|
74528
74536
|
}
|
|
74529
|
-
function
|
|
74537
|
+
function getParameterIdentifierInfoAtPosition(signature, pos) {
|
|
74530
74538
|
var _a;
|
|
74531
74539
|
if (((_a = signature.declaration) == null ? void 0 : _a.kind) === 324 /* JSDocFunctionType */) {
|
|
74532
74540
|
return void 0;
|
|
@@ -74534,10 +74542,16 @@ ${lanes.join("\n")}
|
|
|
74534
74542
|
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
74535
74543
|
if (pos < paramCount) {
|
|
74536
74544
|
const param = signature.parameters[pos];
|
|
74537
|
-
|
|
74545
|
+
const paramIdent = getParameterDeclarationIdentifier(param);
|
|
74546
|
+
return paramIdent ? {
|
|
74547
|
+
parameter: paramIdent,
|
|
74548
|
+
parameterName: param.escapedName,
|
|
74549
|
+
isRestParameter: false
|
|
74550
|
+
} : void 0;
|
|
74538
74551
|
}
|
|
74539
74552
|
const restParameter = signature.parameters[paramCount] || unknownSymbol;
|
|
74540
|
-
|
|
74553
|
+
const restIdent = getParameterDeclarationIdentifier(restParameter);
|
|
74554
|
+
if (!restIdent) {
|
|
74541
74555
|
return void 0;
|
|
74542
74556
|
}
|
|
74543
74557
|
const restType = getTypeOfSymbol(restParameter);
|
|
@@ -74546,18 +74560,19 @@ ${lanes.join("\n")}
|
|
|
74546
74560
|
const index = pos - paramCount;
|
|
74547
74561
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
74548
74562
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
74549
|
-
|
|
74550
|
-
|
|
74551
|
-
isRestTupleElement
|
|
74552
|
-
|
|
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;
|
|
74553
74568
|
}
|
|
74554
74569
|
if (pos === paramCount) {
|
|
74555
|
-
return
|
|
74570
|
+
return { parameter: restIdent, parameterName: restParameter.escapedName, isRestParameter: true };
|
|
74556
74571
|
}
|
|
74557
74572
|
return void 0;
|
|
74558
74573
|
}
|
|
74559
|
-
function
|
|
74560
|
-
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;
|
|
74561
74576
|
}
|
|
74562
74577
|
function isValidDeclarationForTupleLabel(d) {
|
|
74563
74578
|
return d.kind === 202 /* NamedTupleMember */ || isParameter(d) && d.name && isIdentifier(d.name);
|
|
@@ -154166,15 +154181,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
154166
154181
|
}
|
|
154167
154182
|
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional = 3 /* All */, isAmbient = false) {
|
|
154168
154183
|
const declarations = symbol.getDeclarations();
|
|
154169
|
-
const declaration = declarations
|
|
154184
|
+
const declaration = firstOrUndefined(declarations);
|
|
154170
154185
|
const checker = context.program.getTypeChecker();
|
|
154171
154186
|
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
|
|
154172
154187
|
const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */;
|
|
154173
|
-
const declarationName =
|
|
154174
|
-
getNameOfDeclaration(declaration),
|
|
154175
|
-
/*includeTrivia*/
|
|
154176
|
-
false
|
|
154177
|
-
);
|
|
154188
|
+
const declarationName = createDeclarationName(symbol, declaration);
|
|
154178
154189
|
const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */;
|
|
154179
154190
|
let modifierFlags = effectiveModifierFlags & 32 /* Static */;
|
|
154180
154191
|
modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */;
|
|
@@ -154325,6 +154336,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
154325
154336
|
false
|
|
154326
154337
|
);
|
|
154327
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
|
+
}
|
|
154328
154352
|
}
|
|
154329
154353
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
154330
154354
|
const program = context.program;
|
|
@@ -163856,6 +163880,9 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
163856
163880
|
function shouldShowLiteralParameterNameHintsOnly(preferences) {
|
|
163857
163881
|
return preferences.includeInlayParameterNameHints === "literals";
|
|
163858
163882
|
}
|
|
163883
|
+
function shouldUseInteractiveInlayHints(preferences) {
|
|
163884
|
+
return preferences.interactiveInlayHints === true;
|
|
163885
|
+
}
|
|
163859
163886
|
function provideInlayHints(context) {
|
|
163860
163887
|
const { file, program, span, cancellationToken, preferences } = context;
|
|
163861
163888
|
const sourceFileText = file.text;
|
|
@@ -163906,9 +163933,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
163906
163933
|
function isSignatureSupportingReturnAnnotation(node) {
|
|
163907
163934
|
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
|
163908
163935
|
}
|
|
163909
|
-
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
|
+
}
|
|
163910
163943
|
result.push({
|
|
163911
|
-
text:
|
|
163944
|
+
text: hintText,
|
|
163912
163945
|
position,
|
|
163913
163946
|
kind: "Parameter" /* Parameter */,
|
|
163914
163947
|
whitespaceAfter: true
|
|
@@ -163916,7 +163949,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
163916
163949
|
}
|
|
163917
163950
|
function addTypeHints(text, position) {
|
|
163918
163951
|
result.push({
|
|
163919
|
-
text: `: ${
|
|
163952
|
+
text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
|
|
163920
163953
|
position,
|
|
163921
163954
|
kind: "Type" /* Type */,
|
|
163922
163955
|
whitespaceBefore: true
|
|
@@ -163924,7 +163957,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
163924
163957
|
}
|
|
163925
163958
|
function addEnumMemberValueHints(text, position) {
|
|
163926
163959
|
result.push({
|
|
163927
|
-
text: `= ${
|
|
163960
|
+
text: `= ${text}`,
|
|
163928
163961
|
position,
|
|
163929
163962
|
kind: "Enum" /* Enum */,
|
|
163930
163963
|
whitespaceBefore: true
|
|
@@ -163974,6 +164007,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
163974
164007
|
return;
|
|
163975
164008
|
}
|
|
163976
164009
|
let signatureParamPos = 0;
|
|
164010
|
+
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
|
|
163977
164011
|
for (const originalArg of args) {
|
|
163978
164012
|
const arg = skipParentheses(originalArg);
|
|
163979
164013
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
@@ -163994,10 +164028,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
163994
164028
|
}
|
|
163995
164029
|
}
|
|
163996
164030
|
}
|
|
163997
|
-
const
|
|
164031
|
+
const identifierInfo = checker.getParameterIdentifierInfoAtPosition(signature, signatureParamPos);
|
|
163998
164032
|
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
163999
|
-
if (
|
|
164000
|
-
const
|
|
164033
|
+
if (identifierInfo) {
|
|
164034
|
+
const { parameter, parameterName, isRestParameter: isFirstVariadicArgument } = identifierInfo;
|
|
164001
164035
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
164002
164036
|
if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
|
|
164003
164037
|
continue;
|
|
@@ -164006,7 +164040,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164006
164040
|
if (leadingCommentsContainsParameterName(arg, name)) {
|
|
164007
164041
|
continue;
|
|
164008
164042
|
}
|
|
164009
|
-
addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument);
|
|
164043
|
+
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
|
|
164010
164044
|
}
|
|
164011
164045
|
}
|
|
164012
164046
|
}
|
|
@@ -164112,12 +164146,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164112
164146
|
}
|
|
164113
164147
|
return printTypeInSingleLine(signatureParamType);
|
|
164114
164148
|
}
|
|
164115
|
-
function truncation(text, maxLength2) {
|
|
164116
|
-
if (text.length > maxLength2) {
|
|
164117
|
-
return text.substr(0, maxLength2 - "...".length) + "...";
|
|
164118
|
-
}
|
|
164119
|
-
return text;
|
|
164120
|
-
}
|
|
164121
164149
|
function printTypeInSingleLine(type) {
|
|
164122
164150
|
const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
|
|
164123
164151
|
const printer = createPrinterWithRemoveComments();
|
|
@@ -164148,13 +164176,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164148
164176
|
}
|
|
164149
164177
|
return true;
|
|
164150
164178
|
}
|
|
164179
|
+
function getNodeDisplayPart(text, node, sourceFile) {
|
|
164180
|
+
return {
|
|
164181
|
+
text,
|
|
164182
|
+
span: createTextSpanFromNode(node, sourceFile),
|
|
164183
|
+
file: sourceFile.fileName
|
|
164184
|
+
};
|
|
164185
|
+
}
|
|
164151
164186
|
}
|
|
164152
|
-
var
|
|
164187
|
+
var maxTypeHintLength, leadingParameterNameCommentRegexFactory;
|
|
164153
164188
|
var init_inlayHints = __esm({
|
|
164154
164189
|
"src/services/inlayHints.ts"() {
|
|
164155
164190
|
"use strict";
|
|
164156
164191
|
init_ts4();
|
|
164157
|
-
|
|
164192
|
+
maxTypeHintLength = 30;
|
|
164158
164193
|
leadingParameterNameCommentRegexFactory = (name) => {
|
|
164159
164194
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164160
164195
|
};
|
|
@@ -166656,7 +166691,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166656
166691
|
}
|
|
166657
166692
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
|
166658
166693
|
}
|
|
166659
|
-
function
|
|
166694
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
|
166660
166695
|
var _a;
|
|
166661
166696
|
const displayParts = [];
|
|
166662
166697
|
let documentation = [];
|
|
@@ -166665,7 +166700,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166665
166700
|
let symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
|
|
166666
166701
|
let hasAddedSymbolInfo = false;
|
|
166667
166702
|
const isThisExpression = location.kind === 110 /* ThisKeyword */ && isInExpressionContext(location) || isThisInTypeQuery(location);
|
|
166668
|
-
let type;
|
|
166669
166703
|
let documentationFromAlias;
|
|
166670
166704
|
let tagsFromAlias;
|
|
166671
166705
|
let hasMultipleSignatures = false;
|
|
@@ -166694,7 +166728,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166694
166728
|
}
|
|
166695
166729
|
}
|
|
166696
166730
|
let signature;
|
|
166697
|
-
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
166731
|
+
type ?? (type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location));
|
|
166698
166732
|
if (location.parent && location.parent.kind === 211 /* PropertyAccessExpression */) {
|
|
166699
166733
|
const right = location.parent.name;
|
|
166700
166734
|
if (right === location || right && right.getFullWidth() === 0) {
|
|
@@ -166909,12 +166943,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
166909
166943
|
if (declarationName && !hasAddedSymbolInfo) {
|
|
166910
166944
|
const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
|
|
166911
166945
|
const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
|
|
166912
|
-
const resolvedInfo =
|
|
166946
|
+
const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
166913
166947
|
typeChecker,
|
|
166914
166948
|
resolvedSymbol,
|
|
166915
166949
|
getSourceFileOfNode(resolvedNode),
|
|
166916
166950
|
resolvedNode,
|
|
166917
166951
|
declarationName,
|
|
166952
|
+
type,
|
|
166918
166953
|
semanticMeaning,
|
|
166919
166954
|
shouldUseAliasName ? symbol : resolvedSymbol
|
|
166920
166955
|
);
|
|
@@ -167169,6 +167204,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
167169
167204
|
addRange(displayParts, typeParameterParts);
|
|
167170
167205
|
}
|
|
167171
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
|
+
}
|
|
167172
167220
|
function isLocalVariableOrFunction(symbol) {
|
|
167173
167221
|
if (symbol.parent) {
|
|
167174
167222
|
return false;
|
|
@@ -180842,10 +180890,22 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
180842
180890
|
const { file, project } = this.getFileAndProject(args);
|
|
180843
180891
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
180844
180892
|
const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));
|
|
180845
|
-
return hints.map((hint) =>
|
|
180846
|
-
|
|
180847
|
-
|
|
180848
|
-
|
|
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
|
+
});
|
|
180849
180909
|
}
|
|
180850
180910
|
setCompilerOptionsForInferredProjects(args) {
|
|
180851
180911
|
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
|
@@ -183878,6 +183938,7 @@ ${e.message}`;
|
|
|
183878
183938
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
183879
183939
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
183880
183940
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
183941
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
183881
183942
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
183882
183943
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
183883
183944
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -184710,6 +184771,7 @@ ${e.message}`;
|
|
|
184710
184771
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
184711
184772
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
184712
184773
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
184774
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
184713
184775
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
184714
184776
|
isUnaryExpression: () => isUnaryExpression,
|
|
184715
184777
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -186281,6 +186343,7 @@ ${e.message}`;
|
|
|
186281
186343
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
186282
186344
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
186283
186345
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
186346
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
186284
186347
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
186285
186348
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
186286
186349
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -187113,6 +187176,7 @@ ${e.message}`;
|
|
|
187113
187176
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
187114
187177
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
187115
187178
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
187179
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
187116
187180
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
187117
187181
|
isUnaryExpression: () => isUnaryExpression,
|
|
187118
187182
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
package/lib/typescript.d.ts
CHANGED
|
@@ -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;
|