Skip to content

Commit a4786d6

Browse files
committed
Fix dialog controller generics allowing unions
1 parent 2a9f9af commit a4786d6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

frontend/composables/useDialog.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ export class DialogController<
104104
*/
105105
async open(
106106
...args: [
107-
...(Data extends undefined ? [] : [data: Data]),
108-
...(OnFail extends OnFail.Close ? [] : [formAction: DialogFormAction]),
107+
// Type parameters here are intentionally on the right side of `extends`
108+
// to prevent unions from distributing both choices of the conditional.
109+
...(undefined extends Data ? [] : [data: Data]),
110+
...(OnFail.Close extends OnFail ? [] : [formAction: DialogFormAction]),
109111
]
110112
// @ts-expect-error TS can't prove the generic return type is correct.
111-
): OnFail extends OnFail.Close ? Promise<string> : Promise<void> {
113+
): OnFail.Close extends OnFail ? Promise<string> : Promise<void> {
112114
if (this.scope === undefined) {
113115
throw new Error(
114116
"Can't open dialog since no `Dialog` component is using it",

0 commit comments

Comments
 (0)