Add '?' in quick info for optional properties/methods (#23480)
This commit is contained in:
parent
56d83f9572
commit
b00e370605
|
@ -549,6 +549,10 @@ namespace ts.SymbolDisplay {
|
|||
const fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
|
||||
SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing | SymbolFormatFlags.AllowAnyNodeKind);
|
||||
addRange(displayParts, fullSymbolDisplayParts);
|
||||
|
||||
if (symbol.flags & SymbolFlags.Optional) {
|
||||
displayParts.push(punctuationPart(SyntaxKind.QuestionToken));
|
||||
}
|
||||
}
|
||||
|
||||
function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) {
|
||||
|
|
|
@ -12,12 +12,12 @@ const [r0, r1, r2, r3] = ranges;
|
|||
|
||||
// members of spread types only refer to themselves and the resulting property
|
||||
verify.referenceGroups(r0, [{ definition: "(property) A1.a: string", ranges: [r0, r2, r3] }]);
|
||||
verify.referenceGroups(r1, [{ definition: "(property) A2.a: number", ranges: [r1, r2] }]);
|
||||
verify.referenceGroups(r1, [{ definition: "(property) A2.a?: number", ranges: [r1, r2] }]);
|
||||
|
||||
// but the resulting property refers to everything
|
||||
verify.referenceGroups(r2, [
|
||||
{ definition: "(property) A1.a: string", ranges: [r0, r2, r3] },
|
||||
{ definition: "(property) A2.a: number", ranges: [r1] },
|
||||
{ definition: "(property) A2.a?: number", ranges: [r1] },
|
||||
]);
|
||||
|
||||
verify.referenceGroups(r3, [{ definition: "(property) A1.a: string", ranges: [r0, r2, r3] }]);
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
////function f ({ [|next|]: { [|next|]: x} }: Recursive) {
|
||||
////}
|
||||
|
||||
verify.singleReferenceGroup("(property) Recursive.next: Recursive");
|
||||
verify.singleReferenceGroup("(property) Recursive.next?: Recursive");
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
////}
|
||||
|
||||
for (const marker of test.markerNames()) {
|
||||
verify.quickInfoAt(marker, "(property) Recursive.next: Recursive");
|
||||
verify.quickInfoAt(marker, "(property) Recursive.next?: Recursive");
|
||||
}
|
Loading…
Reference in a new issue