Skip to content

fix: Support elementSummaries for inlined union members #2933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/test/converter2/issues/gh2933.ts
Original file line number Diff line number Diff line change
@@ -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 };
}
15 changes: 15 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
])
})
});
Loading