From aa7f23a13c235a2e64f83874c9b467d244a5c23a Mon Sep 17 00:00:00 2001 From: LekoArts Date: Fri, 11 Apr 2025 10:44:44 +0200 Subject: [PATCH] add initial failing test --- src/test/converter2/issues/gh2933.ts | 21 +++++++++++++++++++++ src/test/issues.c2.test.ts | 15 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/converter2/issues/gh2933.ts diff --git a/src/test/converter2/issues/gh2933.ts b/src/test/converter2/issues/gh2933.ts new file mode 100644 index 000000000..27422dd68 --- /dev/null +++ b/src/test/converter2/issues/gh2933.ts @@ -0,0 +1,21 @@ +/** + * @inline + */ +type TestReturn = + /** + * An apple a day keeps the doctor away. + */ + | { kind: 'apple', isHealthy: true } + /** + * A donut a day keeps the doctor not away. + */ + | { kind: 'sweets', isHealthy: false } + +/** + * Returns a random value + */ +export function test(): TestReturn { + return Math.random() > 0.5 + ? { kind: 'apple', isHealthy: true } + : { kind: 'sweets', isHealthy: false }; +} \ No newline at end of file diff --git a/src/test/issues.c2.test.ts b/src/test/issues.c2.test.ts index 2070065af..6eb92f886 100644 --- a/src/test/issues.c2.test.ts +++ b/src/test/issues.c2.test.ts @@ -2115,4 +2115,19 @@ describe("Issue Tests", () => { const EdgeCases = query(project, "EdgeCases"); equal(EdgeCases.typeParameters?.map(t => t.type?.toString()), ["number", undefined]); }); + + it('#2933 support elementSummaries for inlined union members', () => { + const project = convert(); + const test = query(project, "test"); + const sig = test.signatures?.[0]; + + equal(sig?.type?.type, "union"); + equal(sig.type.types.length, 2); + + equal(sig.type.elementSummaries?.length, 2); + equal(sig.type.elementSummaries.map(Comment.combineDisplayParts), [ + "An apple a day keeps the doctor away.", + "A donut a day keeps the doctor not away." + ]) + }) });