Skip to content

Commit 375be0d

Browse files
authored
Merge pull request #6905 from nextcloud-libraries/fix/dialogs--spawnDialogs--types
fix(dialog/spawnDialog): incorrect return type for optional result
2 parents ed1d45b + b97045a commit 375be0d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/functions/dialog/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ type DialogComponent<T extends Component> = 'onClose' extends keyof ComponentPro
1515
? T
1616
: 'Please provide a Dialog Component that supports `@close` event'
1717

18+
/**
19+
* Event payload array normalized to a single value when payload has only one argument,
20+
* including one optional argument
21+
*/
1822
type NormalizedPayload<T> = T extends []
1923
? void
2024
: T extends [infer F]
2125
? F
22-
: T
26+
: T extends { length: 0 | 1, 0?: infer F }
27+
? F | undefined
28+
: T
2329

2430
type ClosePayload<T> = T extends { onClose?: (...args: infer P) => any }
2531
? P

0 commit comments

Comments
 (0)