Improve quick info display on properties belonging to all union contextual type members (#56088)

This commit is contained in:
Mateusz Burzyński 2023-11-03 18:38:28 +01:00 committed by GitHub
parent 10db6524f1
commit fd0936755b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 1 deletions

View File

@ -3282,7 +3282,9 @@ export function getPropertySymbolsFromContextualType(node: ObjectLiteralElementW
// Bad discriminant -- do again without discriminating
return mapDefined(contextualType.types, t => t.getProperty(name));
}
return discriminatedPropertySymbols;
// by eliminating duplicates we might even end up with a single symbol
// that helps with displaying better quick infos on properties of union types
return deduplicate(discriminatedPropertySymbols, equateValues);
}
function isArgumentOfElementAccessExpression(node: Node) {

View File

@ -0,0 +1,45 @@
/// <reference path='fourslash.ts'/>
//// interface Entries {
//// /**
//// * Plugins info...
//// */
//// plugins?: Record<string, Record<string, unknown>>;
//// /**
//// * Output info...
//// */
//// output?: string;
//// /**
//// * Format info...
//// */
//// format?: string;
//// }
////
//// interface Input extends Entries {
//// /**
//// * Input info...
//// */
//// input: string;
//// }
////
//// interface Types extends Entries {
//// /**
//// * Types info...
//// */
//// types: string;
//// }
////
//// type EntriesOptions = Input | Types;
////
//// const options: EntriesOptions[] = [
//// {
//// input: "./src/index.ts",
//// /*1*/output: "./dist/index.mjs",
//// },
//// {
//// types: "./src/types.ts",
//// format: "esm",
//// },
//// ];
verify.quickInfoAt("1", "(property) Entries.output?: string", "Output info...");