(no title)
danvk | 3 months ago
I’d love to read a post explaining how TS conditional types are or are not a form of dependent types. Or, I’d like to understand dependent types well enough to write that post.
danvk | 3 months ago
I’d love to read a post explaining how TS conditional types are or are not a form of dependent types. Or, I’d like to understand dependent types well enough to write that post.
dcre|3 months ago
morcus|3 months ago
``` type PickType<B extends Boolean> = B extends true ? number ? string;
function foo<T extends Boolean>(t: T): PickType<T> { return t ? 42 : "42; } ```
The compiler doesn't seem to get that the type of T is narrowed in the ternary branches, and thus Pick<T> is determined.
The error I get is that a number isn't assignable to a Pick<T>.