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: 2.2.0
Code
type T = 'a' | 'b' const f1 = () => true ? 'a' : 'b' const f2 = () => true ? 'a' : 'a' const v1: T = f1() const v2: T = f2()
Expected behavior:
Both will be ok.
Actual behavior:
Only the former is ok.
index.ts(7,7): error TS2322: Type 'string' is not assignable to type 'T'.
The text was updated successfully, but these errors were encountered:
Minimal repro
const f = () => 'a' // inferred type f: () => string const v: 'a' = f() // Type 'string' is not assignable to type '"a"'
Sorry, something went wrong.
This is working as intended. See discussion here for the rationale.
No branches or pull requests
TypeScript Version: 2.2.0
Code
Expected behavior:
Both will be ok.
Actual behavior:
Only the former is ok.
The text was updated successfully, but these errors were encountered: