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
Consider,
function isString(obj: any): obj is string { return typeof typeof obj === "string"; } function foo(value: (string|number)): number { if (isString(value)) { return value.indexOf('foo') } else return value; } function bar(value: (string|number)): number { if (isString(value)) { return value.indexOf('foo') } return value; }
Expected: Both foo and bar type-check correctly. Received: bar reports that value is not assignable to number.
foo
bar
value
number
Flow analysis could be used here to determine value can only be number in all the code paths that arrive at the final return.
return
The text was updated successfully, but these errors were encountered:
looks like a duplicate of #2388
Sorry, something went wrong.
Search fail. Sorry about that.
No branches or pull requests
Consider,
Expected: Both
foo
andbar
type-check correctly.Received:
bar
reports thatvalue
is not assignable tonumber
.Flow analysis could be used here to determine
value
can only benumber
in all the code paths that arrive at the finalreturn
.The text was updated successfully, but these errors were encountered: