We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript Version: 3.2.1
Search Terms: generic, conditional type, widened
Code
type A = { foo: "a" } type B = { foo: "b" } type C = A | B type Resolve<T extends "a" | "b"> = "a" | "b" extends T ? never : T type GenericResolve<T extends C> = Resolve<T["foo"]> type X = Resolve<"a"> // "a" type Y = Resolve<A["foo"]> // "a" type Z = GenericResolve<A> // never type ResolveWithoutCondition<T extends "a" | "b"> = T type GenericResolveWithoutCondition<T extends C> = ResolveWithoutCondition<T["foo"]> type ZZ = GenericResolveWithoutCondition<A> // "a"
Expected behavior: Z should be "a"
Z
"a"
Actual behavior: Z is never
never
Playground Link: http://www.typescriptlang.org/play/#src=type%20A%20%3D%20%7B%20foo%3A%20%22a%22%20%7D%0D%0Atype%20B%20%3D%20%7B%20foo%3A%20%22b%22%20%7D%0D%0Atype%20C%20%3D%20A%20%7C%20B%0D%0A%0D%0Atype%20Resolve%3CT%20extends%20%22a%22%20%7C%20%22b%22%3E%20%3D%20%22a%22%20%7C%20%22b%22%20extends%20T%20%3F%20never%20%3A%20T%0D%0A%0D%0Atype%20GenericResolve%3CT%20extends%20C%3E%20%3D%20Resolve%3CT%5B%22foo%22%5D%3E%0D%0A%0D%0Atype%20X%20%3D%20Resolve%3C%22a%22%3E%20%2F%2F%20%22a%22%0D%0Atype%20Y%20%3D%20Resolve%3CA%5B%22foo%22%5D%3E%20%2F%2F%20%22a%22%0D%0Atype%20Z%20%3D%20GenericResolve%3CA%3E%20%2F%2F%20never%0D%0A%0D%0Atype%20ResolveWithoutCondition%3CT%20extends%20%22a%22%20%7C%20%22b%22%3E%20%3D%20T%0D%0Atype%20GenericResolveWithoutCondition%3CT%20extends%20C%3E%20%3D%20ResolveWithoutCondition%3CT%5B%22foo%22%5D%3E%0D%0A%0D%0Atype%20ZZ%20%3D%20GenericResolveWithoutCondition%3CA%3E%20%2F%2F%20%22a%22
Related Issues:
Could not find any
The text was updated successfully, but these errors were encountered:
I think this has been fixed by #28718. Try the latest version of master and see if that works.
Sorry, something went wrong.
This is indeed the same issue as #28654 and has been fixed by #28718.
This issue has been marked as a duplicate and has seen no activity in the last day. It has been closed automatic house-keeping purposes.
No branches or pull requests
TypeScript Version: 3.2.1
Search Terms: generic, conditional type, widened
Code
Expected behavior:
Z
should be"a"
Actual behavior:
Z
isnever
Playground Link: http://www.typescriptlang.org/play/#src=type%20A%20%3D%20%7B%20foo%3A%20%22a%22%20%7D%0D%0Atype%20B%20%3D%20%7B%20foo%3A%20%22b%22%20%7D%0D%0Atype%20C%20%3D%20A%20%7C%20B%0D%0A%0D%0Atype%20Resolve%3CT%20extends%20%22a%22%20%7C%20%22b%22%3E%20%3D%20%22a%22%20%7C%20%22b%22%20extends%20T%20%3F%20never%20%3A%20T%0D%0A%0D%0Atype%20GenericResolve%3CT%20extends%20C%3E%20%3D%20Resolve%3CT%5B%22foo%22%5D%3E%0D%0A%0D%0Atype%20X%20%3D%20Resolve%3C%22a%22%3E%20%2F%2F%20%22a%22%0D%0Atype%20Y%20%3D%20Resolve%3CA%5B%22foo%22%5D%3E%20%2F%2F%20%22a%22%0D%0Atype%20Z%20%3D%20GenericResolve%3CA%3E%20%2F%2F%20never%0D%0A%0D%0Atype%20ResolveWithoutCondition%3CT%20extends%20%22a%22%20%7C%20%22b%22%3E%20%3D%20T%0D%0Atype%20GenericResolveWithoutCondition%3CT%20extends%20C%3E%20%3D%20ResolveWithoutCondition%3CT%5B%22foo%22%5D%3E%0D%0A%0D%0Atype%20ZZ%20%3D%20GenericResolveWithoutCondition%3CA%3E%20%2F%2F%20%22a%22
Related Issues:
Could not find any
The text was updated successfully, but these errors were encountered: