Closed
Description
openedon Jul 19, 2024
🔎 Search Terms
infer unknow
🕗 Version & Regression Information
- This is a crash
- This changed between versions ______ and _______
- This changed in commit or PR _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
No response
💻 Code
// Your code here
🙁 Actual behavior
type MyType<T> = T extends (infer R) & string ? R : never
type Result = MyType<string> // unknown
type MyType<T> = T extends (infer R) & string ? R : never
type Result = MyType<'abc'> // abc
Why is the Result here unknown instead of string? Doesn't infer infer a more precise type? If not, then why is Result abc instead of string when T is abc?
🙂 Expected behavior
type MyType<T> = T extends (infer R) & string ? R : never
type Result = MyType<string> // Expected string
Additional information about the issue
No response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
This behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options