Skip to content

Commit fd09367

Browse files
authored
Improve quick info display on properties belonging to all union contextual type members (#56088)
1 parent 10db652 commit fd09367

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

src/services/services.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3282,7 +3282,9 @@ export function getPropertySymbolsFromContextualType(node: ObjectLiteralElementW
32823282
// Bad discriminant -- do again without discriminating
32833283
return mapDefined(contextualType.types, t => t.getProperty(name));
32843284
}
3285-
return discriminatedPropertySymbols;
3285+
// by eliminating duplicates we might even end up with a single symbol
3286+
// that helps with displaying better quick infos on properties of union types
3287+
return deduplicate(discriminatedPropertySymbols, equateValues);
32863288
}
32873289

32883290
function isArgumentOfElementAccessExpression(node: Node) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
//// interface Entries {
4+
//// /**
5+
//// * Plugins info...
6+
//// */
7+
//// plugins?: Record<string, Record<string, unknown>>;
8+
//// /**
9+
//// * Output info...
10+
//// */
11+
//// output?: string;
12+
//// /**
13+
//// * Format info...
14+
//// */
15+
//// format?: string;
16+
//// }
17+
////
18+
//// interface Input extends Entries {
19+
//// /**
20+
//// * Input info...
21+
//// */
22+
//// input: string;
23+
//// }
24+
////
25+
//// interface Types extends Entries {
26+
//// /**
27+
//// * Types info...
28+
//// */
29+
//// types: string;
30+
//// }
31+
////
32+
//// type EntriesOptions = Input | Types;
33+
////
34+
//// const options: EntriesOptions[] = [
35+
//// {
36+
//// input: "./src/index.ts",
37+
//// /*1*/output: "./dist/index.mjs",
38+
//// },
39+
//// {
40+
//// types: "./src/types.ts",
41+
//// format: "esm",
42+
//// },
43+
//// ];
44+
45+
verify.quickInfoAt("1", "(property) Entries.output?: string", "Output info...");

0 commit comments

Comments
 (0)