← Back to context

Comment by morcus

3 months ago

I just tried this, and I couldn't quite get it to work.

``` 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>.