Add '?' in quick info for optional properties/methods (#23480)

This commit is contained in:
Andy 2018-04-17 12:42:23 -07:00 committed by GitHub
parent 56d83f9572
commit b00e370605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View file

@ -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) {

View file

@ -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] }]);

View file

@ -8,4 +8,4 @@
////function f ({ [|next|]: { [|next|]: x} }: Recursive) {
////}
verify.singleReferenceGroup("(property) Recursive.next: Recursive");
verify.singleReferenceGroup("(property) Recursive.next?: Recursive");

View file

@ -9,5 +9,5 @@
////}
for (const marker of test.markerNames()) {
verify.quickInfoAt(marker, "(property) Recursive.next: Recursive");
verify.quickInfoAt(marker, "(property) Recursive.next?: Recursive");
}