Closed as not planned
Description
π Search Terms
conditional types, resolve, template
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about conditional types, templates
β― Playground Link
π» Code
type A = {
a: string
}
type B = {
b: string
}
type MyType<T extends A | B> =
T extends A ? 'a' : 'b'
function foo<T extends A>(): void {
const x: MyType<T> = 'a'
x
}
π Actual behavior
Type "a" is not assignable to MyType
π Expected behavior
Type "a" is assignable to MyType
Additional information about the issue
This additional snippet works as expected:
const x: MyType<A1> = 'a'
x
type A1 = {
a: string
a1: string
}