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/tsserver.js
CHANGED
|
@@ -970,6 +970,7 @@ __export(server_exports, {
|
|
|
970
970
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
971
971
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
972
972
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
973
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
973
974
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
974
975
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
975
976
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -1802,6 +1803,7 @@ __export(server_exports, {
|
|
|
1802
1803
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
1803
1804
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
1804
1805
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
1806
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
1805
1807
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
1806
1808
|
isUnaryExpression: () => isUnaryExpression,
|
|
1807
1809
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -2327,7 +2329,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2327
2329
|
|
|
2328
2330
|
// src/compiler/corePublic.ts
|
|
2329
2331
|
var versionMajorMinor = "5.2";
|
|
2330
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2332
|
+
var version = `${versionMajorMinor}.0-dev.20230721`;
|
|
2331
2333
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2332
2334
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2333
2335
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -21601,6 +21603,18 @@ function getTextOfJsxNamespacedName(node) {
|
|
|
21601
21603
|
function intrinsicTagNameToString(node) {
|
|
21602
21604
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
21603
21605
|
}
|
|
21606
|
+
function isTypeUsableAsPropertyName(type) {
|
|
21607
|
+
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
21608
|
+
}
|
|
21609
|
+
function getPropertyNameFromType(type) {
|
|
21610
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
21611
|
+
return type.escapedName;
|
|
21612
|
+
}
|
|
21613
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
21614
|
+
return escapeLeadingUnderscores("" + type.value);
|
|
21615
|
+
}
|
|
21616
|
+
return Debug.fail();
|
|
21617
|
+
}
|
|
21604
21618
|
|
|
21605
21619
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21606
21620
|
function createBaseNodeFactory() {
|
|
@@ -35109,10 +35123,14 @@ var Parser;
|
|
|
35109
35123
|
case 124 /* ProtectedKeyword */:
|
|
35110
35124
|
case 125 /* PublicKeyword */:
|
|
35111
35125
|
case 148 /* ReadonlyKeyword */:
|
|
35126
|
+
const previousToken = token();
|
|
35112
35127
|
nextToken();
|
|
35113
35128
|
if (scanner2.hasPrecedingLineBreak()) {
|
|
35114
35129
|
return false;
|
|
35115
35130
|
}
|
|
35131
|
+
if (previousToken === 138 /* DeclareKeyword */ && token() === 156 /* TypeKeyword */) {
|
|
35132
|
+
return true;
|
|
35133
|
+
}
|
|
35116
35134
|
continue;
|
|
35117
35135
|
case 162 /* GlobalKeyword */:
|
|
35118
35136
|
nextToken();
|
|
@@ -35477,14 +35495,14 @@ var Parser;
|
|
|
35477
35495
|
function parseObjectBindingPattern() {
|
|
35478
35496
|
const pos = getNodePos();
|
|
35479
35497
|
parseExpected(19 /* OpenBraceToken */);
|
|
35480
|
-
const elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
|
|
35498
|
+
const elements = allowInAnd(() => parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement));
|
|
35481
35499
|
parseExpected(20 /* CloseBraceToken */);
|
|
35482
35500
|
return finishNode(factory2.createObjectBindingPattern(elements), pos);
|
|
35483
35501
|
}
|
|
35484
35502
|
function parseArrayBindingPattern() {
|
|
35485
35503
|
const pos = getNodePos();
|
|
35486
35504
|
parseExpected(23 /* OpenBracketToken */);
|
|
35487
|
-
const elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
|
|
35505
|
+
const elements = allowInAnd(() => parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement));
|
|
35488
35506
|
parseExpected(24 /* CloseBracketToken */);
|
|
35489
35507
|
return finishNode(factory2.createArrayBindingPattern(elements), pos);
|
|
35490
35508
|
}
|
|
@@ -36002,6 +36020,9 @@ var Parser;
|
|
|
36002
36020
|
}
|
|
36003
36021
|
function parseTypeAliasDeclaration(pos, hasJSDoc, modifiers) {
|
|
36004
36022
|
parseExpected(156 /* TypeKeyword */);
|
|
36023
|
+
if (scanner2.hasPrecedingLineBreak()) {
|
|
36024
|
+
parseErrorAtCurrentToken(Diagnostics.Line_break_not_permitted_here);
|
|
36025
|
+
}
|
|
36005
36026
|
const name = parseIdentifier();
|
|
36006
36027
|
const typeParameters = parseTypeParameters();
|
|
36007
36028
|
parseExpected(64 /* EqualsToken */);
|
|
@@ -47818,7 +47839,7 @@ function createTypeChecker(host) {
|
|
|
47818
47839
|
return node ? getTypeFromTypeNode(node) : errorType;
|
|
47819
47840
|
},
|
|
47820
47841
|
getParameterType: getTypeAtPosition,
|
|
47821
|
-
|
|
47842
|
+
getParameterIdentifierInfoAtPosition,
|
|
47822
47843
|
getPromisedTypeOfPromise,
|
|
47823
47844
|
getAwaitedType: (type) => getAwaitedType(type),
|
|
47824
47845
|
getReturnTypeOfSignature,
|
|
@@ -49259,7 +49280,7 @@ function createTypeChecker(host) {
|
|
|
49259
49280
|
if (name === "const" && isConstAssertion(location)) {
|
|
49260
49281
|
return void 0;
|
|
49261
49282
|
}
|
|
49262
|
-
if (
|
|
49283
|
+
if (isModuleOrEnumDeclaration(location) && lastLocation && location.name === lastLocation) {
|
|
49263
49284
|
lastLocation = location;
|
|
49264
49285
|
location = location.parent;
|
|
49265
49286
|
}
|
|
@@ -56281,7 +56302,7 @@ function createTypeChecker(host) {
|
|
|
56281
56302
|
false,
|
|
56282
56303
|
definedInMethod && !definedInConstructor
|
|
56283
56304
|
));
|
|
56284
|
-
if (symbol.valueDeclaration && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
|
|
56305
|
+
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
|
|
56285
56306
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
56286
56307
|
return anyType;
|
|
56287
56308
|
}
|
|
@@ -57560,9 +57581,6 @@ function createTypeChecker(host) {
|
|
|
57560
57581
|
}
|
|
57561
57582
|
return type;
|
|
57562
57583
|
}
|
|
57563
|
-
function isTypeUsableAsPropertyName(type) {
|
|
57564
|
-
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
57565
|
-
}
|
|
57566
57584
|
function isLateBindableName(node) {
|
|
57567
57585
|
if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
|
|
57568
57586
|
return false;
|
|
@@ -57583,15 +57601,6 @@ function createTypeChecker(host) {
|
|
|
57583
57601
|
function isNonBindableDynamicName(node) {
|
|
57584
57602
|
return isDynamicName(node) && !isLateBindableName(node);
|
|
57585
57603
|
}
|
|
57586
|
-
function getPropertyNameFromType(type) {
|
|
57587
|
-
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
57588
|
-
return type.escapedName;
|
|
57589
|
-
}
|
|
57590
|
-
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
57591
|
-
return escapeLeadingUnderscores("" + type.value);
|
|
57592
|
-
}
|
|
57593
|
-
return Debug.fail();
|
|
57594
|
-
}
|
|
57595
57604
|
function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
|
|
57596
57605
|
Debug.assert(!!(getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol.");
|
|
57597
57606
|
symbol.flags |= symbolFlags;
|
|
@@ -57641,6 +57650,7 @@ function createTypeChecker(host) {
|
|
|
57641
57650
|
return links.resolvedSymbol;
|
|
57642
57651
|
}
|
|
57643
57652
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
57653
|
+
var _a, _b, _c;
|
|
57644
57654
|
const links = getSymbolLinks(symbol);
|
|
57645
57655
|
if (!links[resolutionKind]) {
|
|
57646
57656
|
const isStatic2 = resolutionKind === "resolvedExports" /* resolvedExports */;
|
|
@@ -57659,7 +57669,7 @@ function createTypeChecker(host) {
|
|
|
57659
57669
|
}
|
|
57660
57670
|
}
|
|
57661
57671
|
}
|
|
57662
|
-
const assignments = symbol.assignmentDeclarationMembers;
|
|
57672
|
+
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;
|
|
57663
57673
|
if (assignments) {
|
|
57664
57674
|
const decls = arrayFrom(assignments.values());
|
|
57665
57675
|
for (const member of decls) {
|
|
@@ -58237,20 +58247,17 @@ function createTypeChecker(host) {
|
|
|
58237
58247
|
setStructuredTypeMembers(type, members2, callSignatures, constructSignatures, indexInfos2);
|
|
58238
58248
|
return;
|
|
58239
58249
|
}
|
|
58240
|
-
let members =
|
|
58250
|
+
let members = getExportsOfSymbol(symbol);
|
|
58241
58251
|
let indexInfos;
|
|
58242
|
-
if (symbol
|
|
58243
|
-
|
|
58244
|
-
|
|
58245
|
-
|
|
58246
|
-
|
|
58247
|
-
|
|
58248
|
-
|
|
58249
|
-
|
|
58250
|
-
|
|
58251
|
-
});
|
|
58252
|
-
members = varsOnly;
|
|
58253
|
-
}
|
|
58252
|
+
if (symbol === globalThisSymbol) {
|
|
58253
|
+
const varsOnly = /* @__PURE__ */ new Map();
|
|
58254
|
+
members.forEach((p) => {
|
|
58255
|
+
var _a;
|
|
58256
|
+
if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) == null ? void 0 : _a.length) && every(p.declarations, isAmbientModule))) {
|
|
58257
|
+
varsOnly.set(p.escapedName, p);
|
|
58258
|
+
}
|
|
58259
|
+
});
|
|
58260
|
+
members = varsOnly;
|
|
58254
58261
|
}
|
|
58255
58262
|
let baseConstructorIndexInfo;
|
|
58256
58263
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
|
@@ -70343,12 +70350,15 @@ function createTypeChecker(host) {
|
|
|
70343
70350
|
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
70344
70351
|
}
|
|
70345
70352
|
const target = getReferenceCandidate(expr.right);
|
|
70346
|
-
|
|
70347
|
-
|
|
70348
|
-
if (
|
|
70353
|
+
if (containsMissingType(type) && isAccessExpression(reference) && isMatchingReference(reference.expression, target)) {
|
|
70354
|
+
const leftType = getTypeOfExpression(expr.left);
|
|
70355
|
+
if (isTypeUsableAsPropertyName(leftType) && getAccessedPropertyName(reference) === getPropertyNameFromType(leftType)) {
|
|
70349
70356
|
return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */);
|
|
70350
70357
|
}
|
|
70351
|
-
|
|
70358
|
+
}
|
|
70359
|
+
if (isMatchingReference(reference, target)) {
|
|
70360
|
+
const leftType = getTypeOfExpression(expr.left);
|
|
70361
|
+
if (isTypeUsableAsPropertyName(leftType)) {
|
|
70352
70362
|
return narrowTypeByInKeyword(type, leftType, assumeTrue);
|
|
70353
70363
|
}
|
|
70354
70364
|
}
|
|
@@ -76759,7 +76769,7 @@ function createTypeChecker(host) {
|
|
|
76759
76769
|
}
|
|
76760
76770
|
return restParameter.escapedName;
|
|
76761
76771
|
}
|
|
76762
|
-
function
|
|
76772
|
+
function getParameterIdentifierInfoAtPosition(signature, pos) {
|
|
76763
76773
|
var _a;
|
|
76764
76774
|
if (((_a = signature.declaration) == null ? void 0 : _a.kind) === 324 /* JSDocFunctionType */) {
|
|
76765
76775
|
return void 0;
|
|
@@ -76767,10 +76777,16 @@ function createTypeChecker(host) {
|
|
|
76767
76777
|
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
76768
76778
|
if (pos < paramCount) {
|
|
76769
76779
|
const param = signature.parameters[pos];
|
|
76770
|
-
|
|
76780
|
+
const paramIdent = getParameterDeclarationIdentifier(param);
|
|
76781
|
+
return paramIdent ? {
|
|
76782
|
+
parameter: paramIdent,
|
|
76783
|
+
parameterName: param.escapedName,
|
|
76784
|
+
isRestParameter: false
|
|
76785
|
+
} : void 0;
|
|
76771
76786
|
}
|
|
76772
76787
|
const restParameter = signature.parameters[paramCount] || unknownSymbol;
|
|
76773
|
-
|
|
76788
|
+
const restIdent = getParameterDeclarationIdentifier(restParameter);
|
|
76789
|
+
if (!restIdent) {
|
|
76774
76790
|
return void 0;
|
|
76775
76791
|
}
|
|
76776
76792
|
const restType = getTypeOfSymbol(restParameter);
|
|
@@ -76779,18 +76795,19 @@ function createTypeChecker(host) {
|
|
|
76779
76795
|
const index = pos - paramCount;
|
|
76780
76796
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
76781
76797
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
76782
|
-
|
|
76783
|
-
|
|
76784
|
-
isRestTupleElement
|
|
76785
|
-
|
|
76798
|
+
if (associatedName) {
|
|
76799
|
+
Debug.assert(isIdentifier(associatedName.name));
|
|
76800
|
+
return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
|
|
76801
|
+
}
|
|
76802
|
+
return void 0;
|
|
76786
76803
|
}
|
|
76787
76804
|
if (pos === paramCount) {
|
|
76788
|
-
return
|
|
76805
|
+
return { parameter: restIdent, parameterName: restParameter.escapedName, isRestParameter: true };
|
|
76789
76806
|
}
|
|
76790
76807
|
return void 0;
|
|
76791
76808
|
}
|
|
76792
|
-
function
|
|
76793
|
-
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name);
|
|
76809
|
+
function getParameterDeclarationIdentifier(symbol) {
|
|
76810
|
+
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name) && symbol.valueDeclaration.name;
|
|
76794
76811
|
}
|
|
76795
76812
|
function isValidDeclarationForTupleLabel(d) {
|
|
76796
76813
|
return d.kind === 202 /* NamedTupleMember */ || isParameter(d) && d.name && isIdentifier(d.name);
|
|
@@ -155118,15 +155135,11 @@ var PreserveOptionalFlags = /* @__PURE__ */ ((PreserveOptionalFlags2) => {
|
|
|
155118
155135
|
})(PreserveOptionalFlags || {});
|
|
155119
155136
|
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional = 3 /* All */, isAmbient = false) {
|
|
155120
155137
|
const declarations = symbol.getDeclarations();
|
|
155121
|
-
const declaration = declarations
|
|
155138
|
+
const declaration = firstOrUndefined(declarations);
|
|
155122
155139
|
const checker = context.program.getTypeChecker();
|
|
155123
155140
|
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
|
|
155124
155141
|
const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */;
|
|
155125
|
-
const declarationName =
|
|
155126
|
-
getNameOfDeclaration(declaration),
|
|
155127
|
-
/*includeTrivia*/
|
|
155128
|
-
false
|
|
155129
|
-
);
|
|
155142
|
+
const declarationName = createDeclarationName(symbol, declaration);
|
|
155130
155143
|
const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */;
|
|
155131
155144
|
let modifierFlags = effectiveModifierFlags & 32 /* Static */;
|
|
155132
155145
|
modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */;
|
|
@@ -155277,6 +155290,19 @@ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, con
|
|
|
155277
155290
|
false
|
|
155278
155291
|
);
|
|
155279
155292
|
}
|
|
155293
|
+
function createDeclarationName(symbol2, declaration2) {
|
|
155294
|
+
if (getCheckFlags(symbol2) & 262144 /* Mapped */) {
|
|
155295
|
+
const nameType = symbol2.links.nameType;
|
|
155296
|
+
if (nameType && isTypeUsableAsPropertyName(nameType)) {
|
|
155297
|
+
return factory.createIdentifier(unescapeLeadingUnderscores(getPropertyNameFromType(nameType)));
|
|
155298
|
+
}
|
|
155299
|
+
}
|
|
155300
|
+
return getSynthesizedDeepClone(
|
|
155301
|
+
getNameOfDeclaration(declaration2),
|
|
155302
|
+
/*includeTrivia*/
|
|
155303
|
+
false
|
|
155304
|
+
);
|
|
155305
|
+
}
|
|
155280
155306
|
}
|
|
155281
155307
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
155282
155308
|
const program = context.program;
|
|
@@ -164494,7 +164520,7 @@ __export(ts_InlayHints_exports, {
|
|
|
164494
164520
|
});
|
|
164495
164521
|
|
|
164496
164522
|
// src/services/inlayHints.ts
|
|
164497
|
-
var
|
|
164523
|
+
var maxTypeHintLength = 30;
|
|
164498
164524
|
var leadingParameterNameCommentRegexFactory = (name) => {
|
|
164499
164525
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164500
164526
|
};
|
|
@@ -164504,6 +164530,9 @@ function shouldShowParameterNameHints(preferences) {
|
|
|
164504
164530
|
function shouldShowLiteralParameterNameHintsOnly(preferences) {
|
|
164505
164531
|
return preferences.includeInlayParameterNameHints === "literals";
|
|
164506
164532
|
}
|
|
164533
|
+
function shouldUseInteractiveInlayHints(preferences) {
|
|
164534
|
+
return preferences.interactiveInlayHints === true;
|
|
164535
|
+
}
|
|
164507
164536
|
function provideInlayHints(context) {
|
|
164508
164537
|
const { file, program, span, cancellationToken, preferences } = context;
|
|
164509
164538
|
const sourceFileText = file.text;
|
|
@@ -164554,9 +164583,15 @@ function provideInlayHints(context) {
|
|
|
164554
164583
|
function isSignatureSupportingReturnAnnotation(node) {
|
|
164555
164584
|
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
|
164556
164585
|
}
|
|
164557
|
-
function addParameterHints(text, position, isFirstVariadicArgument) {
|
|
164586
|
+
function addParameterHints(text, parameter, position, isFirstVariadicArgument, sourceFile) {
|
|
164587
|
+
let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
|
|
164588
|
+
if (shouldUseInteractiveInlayHints(preferences)) {
|
|
164589
|
+
hintText = [getNodeDisplayPart(hintText, parameter, sourceFile), { text: ":" }];
|
|
164590
|
+
} else {
|
|
164591
|
+
hintText += ":";
|
|
164592
|
+
}
|
|
164558
164593
|
result.push({
|
|
164559
|
-
text:
|
|
164594
|
+
text: hintText,
|
|
164560
164595
|
position,
|
|
164561
164596
|
kind: "Parameter" /* Parameter */,
|
|
164562
164597
|
whitespaceAfter: true
|
|
@@ -164564,7 +164599,7 @@ function provideInlayHints(context) {
|
|
|
164564
164599
|
}
|
|
164565
164600
|
function addTypeHints(text, position) {
|
|
164566
164601
|
result.push({
|
|
164567
|
-
text: `: ${
|
|
164602
|
+
text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
|
|
164568
164603
|
position,
|
|
164569
164604
|
kind: "Type" /* Type */,
|
|
164570
164605
|
whitespaceBefore: true
|
|
@@ -164572,7 +164607,7 @@ function provideInlayHints(context) {
|
|
|
164572
164607
|
}
|
|
164573
164608
|
function addEnumMemberValueHints(text, position) {
|
|
164574
164609
|
result.push({
|
|
164575
|
-
text: `= ${
|
|
164610
|
+
text: `= ${text}`,
|
|
164576
164611
|
position,
|
|
164577
164612
|
kind: "Enum" /* Enum */,
|
|
164578
164613
|
whitespaceBefore: true
|
|
@@ -164622,6 +164657,7 @@ function provideInlayHints(context) {
|
|
|
164622
164657
|
return;
|
|
164623
164658
|
}
|
|
164624
164659
|
let signatureParamPos = 0;
|
|
164660
|
+
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
|
|
164625
164661
|
for (const originalArg of args) {
|
|
164626
164662
|
const arg = skipParentheses(originalArg);
|
|
164627
164663
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
@@ -164642,10 +164678,10 @@ function provideInlayHints(context) {
|
|
|
164642
164678
|
}
|
|
164643
164679
|
}
|
|
164644
164680
|
}
|
|
164645
|
-
const
|
|
164681
|
+
const identifierInfo = checker.getParameterIdentifierInfoAtPosition(signature, signatureParamPos);
|
|
164646
164682
|
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
164647
|
-
if (
|
|
164648
|
-
const
|
|
164683
|
+
if (identifierInfo) {
|
|
164684
|
+
const { parameter, parameterName, isRestParameter: isFirstVariadicArgument } = identifierInfo;
|
|
164649
164685
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
164650
164686
|
if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
|
|
164651
164687
|
continue;
|
|
@@ -164654,7 +164690,7 @@ function provideInlayHints(context) {
|
|
|
164654
164690
|
if (leadingCommentsContainsParameterName(arg, name)) {
|
|
164655
164691
|
continue;
|
|
164656
164692
|
}
|
|
164657
|
-
addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument);
|
|
164693
|
+
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
|
|
164658
164694
|
}
|
|
164659
164695
|
}
|
|
164660
164696
|
}
|
|
@@ -164760,12 +164796,6 @@ function provideInlayHints(context) {
|
|
|
164760
164796
|
}
|
|
164761
164797
|
return printTypeInSingleLine(signatureParamType);
|
|
164762
164798
|
}
|
|
164763
|
-
function truncation(text, maxLength2) {
|
|
164764
|
-
if (text.length > maxLength2) {
|
|
164765
|
-
return text.substr(0, maxLength2 - "...".length) + "...";
|
|
164766
|
-
}
|
|
164767
|
-
return text;
|
|
164768
|
-
}
|
|
164769
164799
|
function printTypeInSingleLine(type) {
|
|
164770
164800
|
const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
|
|
164771
164801
|
const printer = createPrinterWithRemoveComments();
|
|
@@ -164796,6 +164826,13 @@ function provideInlayHints(context) {
|
|
|
164796
164826
|
}
|
|
164797
164827
|
return true;
|
|
164798
164828
|
}
|
|
164829
|
+
function getNodeDisplayPart(text, node, sourceFile) {
|
|
164830
|
+
return {
|
|
164831
|
+
text,
|
|
164832
|
+
span: createTextSpanFromNode(node, sourceFile),
|
|
164833
|
+
file: sourceFile.fileName
|
|
164834
|
+
};
|
|
164835
|
+
}
|
|
164799
164836
|
}
|
|
164800
164837
|
|
|
164801
164838
|
// src/services/_namespaces/ts.JsDoc.ts
|
|
@@ -167215,7 +167252,7 @@ function getSymbolModifiers(typeChecker, symbol) {
|
|
|
167215
167252
|
}
|
|
167216
167253
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
|
167217
167254
|
}
|
|
167218
|
-
function
|
|
167255
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
|
167219
167256
|
var _a;
|
|
167220
167257
|
const displayParts = [];
|
|
167221
167258
|
let documentation = [];
|
|
@@ -167224,7 +167261,6 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167224
167261
|
let symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
|
|
167225
167262
|
let hasAddedSymbolInfo = false;
|
|
167226
167263
|
const isThisExpression = location.kind === 110 /* ThisKeyword */ && isInExpressionContext(location) || isThisInTypeQuery(location);
|
|
167227
|
-
let type;
|
|
167228
167264
|
let documentationFromAlias;
|
|
167229
167265
|
let tagsFromAlias;
|
|
167230
167266
|
let hasMultipleSignatures = false;
|
|
@@ -167253,7 +167289,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167253
167289
|
}
|
|
167254
167290
|
}
|
|
167255
167291
|
let signature;
|
|
167256
|
-
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
167292
|
+
type ?? (type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location));
|
|
167257
167293
|
if (location.parent && location.parent.kind === 211 /* PropertyAccessExpression */) {
|
|
167258
167294
|
const right = location.parent.name;
|
|
167259
167295
|
if (right === location || right && right.getFullWidth() === 0) {
|
|
@@ -167468,12 +167504,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167468
167504
|
if (declarationName && !hasAddedSymbolInfo) {
|
|
167469
167505
|
const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
|
|
167470
167506
|
const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
|
|
167471
|
-
const resolvedInfo =
|
|
167507
|
+
const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167472
167508
|
typeChecker,
|
|
167473
167509
|
resolvedSymbol,
|
|
167474
167510
|
getSourceFileOfNode(resolvedNode),
|
|
167475
167511
|
resolvedNode,
|
|
167476
167512
|
declarationName,
|
|
167513
|
+
type,
|
|
167477
167514
|
semanticMeaning,
|
|
167478
167515
|
shouldUseAliasName ? symbol : resolvedSymbol
|
|
167479
167516
|
);
|
|
@@ -167728,6 +167765,19 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167728
167765
|
addRange(displayParts, typeParameterParts);
|
|
167729
167766
|
}
|
|
167730
167767
|
}
|
|
167768
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
|
|
167769
|
+
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167770
|
+
typeChecker,
|
|
167771
|
+
symbol,
|
|
167772
|
+
sourceFile,
|
|
167773
|
+
enclosingDeclaration,
|
|
167774
|
+
location,
|
|
167775
|
+
/*type*/
|
|
167776
|
+
void 0,
|
|
167777
|
+
semanticMeaning,
|
|
167778
|
+
alias
|
|
167779
|
+
);
|
|
167780
|
+
}
|
|
167731
167781
|
function isLocalVariableOrFunction(symbol) {
|
|
167732
167782
|
if (symbol.parent) {
|
|
167733
167783
|
return false;
|
|
@@ -172737,6 +172787,7 @@ __export(ts_exports2, {
|
|
|
172737
172787
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
172738
172788
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
172739
172789
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
172790
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
172740
172791
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
172741
172792
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
172742
172793
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -173569,6 +173620,7 @@ __export(ts_exports2, {
|
|
|
173569
173620
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
173570
173621
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
173571
173622
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
173623
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
173572
173624
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
173573
173625
|
isUnaryExpression: () => isUnaryExpression,
|
|
173574
173626
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -183427,10 +183479,22 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
183427
183479
|
const { file, project } = this.getFileAndProject(args);
|
|
183428
183480
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
183429
183481
|
const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));
|
|
183430
|
-
return hints.map((hint) =>
|
|
183431
|
-
|
|
183432
|
-
|
|
183433
|
-
|
|
183482
|
+
return hints.map((hint) => {
|
|
183483
|
+
const { text, position } = hint;
|
|
183484
|
+
const hintText = typeof text === "string" ? text : text.map(({ text: text2, span, file: file2 }) => ({
|
|
183485
|
+
text: text2,
|
|
183486
|
+
span: span && {
|
|
183487
|
+
start: scriptInfo.positionToLineOffset(span.start),
|
|
183488
|
+
end: scriptInfo.positionToLineOffset(span.start + span.length),
|
|
183489
|
+
file: file2
|
|
183490
|
+
}
|
|
183491
|
+
}));
|
|
183492
|
+
return {
|
|
183493
|
+
...hint,
|
|
183494
|
+
position: scriptInfo.positionToLineOffset(position),
|
|
183495
|
+
text: hintText
|
|
183496
|
+
};
|
|
183497
|
+
});
|
|
183434
183498
|
}
|
|
183435
183499
|
setCompilerOptionsForInferredProjects(args) {
|
|
183436
183500
|
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
|
@@ -187251,6 +187315,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
187251
187315
|
getPropertyAssignmentAliasLikeExpression,
|
|
187252
187316
|
getPropertyNameForPropertyNameNode,
|
|
187253
187317
|
getPropertyNameForUniqueESSymbol,
|
|
187318
|
+
getPropertyNameFromType,
|
|
187254
187319
|
getPropertyNameOfBindingOrAssignmentElement,
|
|
187255
187320
|
getPropertySymbolFromBindingElement,
|
|
187256
187321
|
getPropertySymbolsFromContextualType,
|
|
@@ -188083,6 +188148,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188083
188148
|
isTypeQueryNode,
|
|
188084
188149
|
isTypeReferenceNode,
|
|
188085
188150
|
isTypeReferenceType,
|
|
188151
|
+
isTypeUsableAsPropertyName,
|
|
188086
188152
|
isUMDExportSymbol,
|
|
188087
188153
|
isUnaryExpression,
|
|
188088
188154
|
isUnaryExpressionWithWrite,
|
package/lib/tsserverlibrary.d.ts
CHANGED
|
@@ -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;
|