File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,14 +3,18 @@ import { SIGNAL_RESET } from "./constants"
33
44/**
55 * Distributive helper to validate the shape of the updater function
6- * and prevent covariance
6+ * and prevent covariance. Distributes over both T and U so union state
7+ * types work (updater can return any member of the union).
78 */
8- // biome-ignore lint/suspicious/noExplicitAny: Expected to prevent covariance
9- type ValidateShape < T , U > = T extends any
10- ? U extends T
11- ? U extends object
12- ? { [ K in keyof U ] : K extends keyof T ? T [ K ] : never }
13- : U
9+ // biome-ignore lint/suspicious/noExplicitAny: distributive conditional over U and T for union support
10+ type ValidateShape < T , U > = U extends any
11+ ? // biome-ignore lint/suspicious/noExplicitAny: distributive over T
12+ T extends any
13+ ? U extends T
14+ ? U extends object
15+ ? { [ K in keyof U ] : K extends keyof T ? T [ K ] : never }
16+ : U
17+ : never
1418 : never
1519 : never
1620
You can’t perform that action at this time.
0 commit comments