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
Could be a duplicate but difficult to construct an issue search to discern.
Problem shows with typescript@latest version 3.0.1.
typescript@latest
3.0.1
Given nature of problem suspect that it would not have been fixed in typescript@next. Apologies for not testing.
typescript@next
type inference error argument
Code
// A *self-contained* demonstration of the problem follows... // Just paste this code into your favorite TypeScript IDE
function foobar_good(arg: unknown): void | number { if (typeof arg != 'number') { return } return arg; } function foobar_bad(arg: unknown): void | number { if (typeof arg != 'number') { return } arg = arg; return arg; }
[ts] Type 'unknown' is not assignable to type 'number | void'. Type 'unknown' is not assignable to type 'void'.
Expected behavior: Should compile.
Actual behavior: Does not compile.
The text was updated successfully, but these errors were encountered:
Related to #25720. We should handle assignments to unknown as narrowing. Simplified repro:
unknown
function f(p: unknown): number { p = 2; return p * 2; }
Sorry, something went wrong.
No branches or pull requests
Could be a duplicate but difficult to construct an issue search to discern.
Problem shows with
typescript@latest
version3.0.1
.Given nature of problem suspect that it would not have been fixed in
typescript@next
. Apologies for not testing.type inference error argument
Code
Expected behavior:
Should compile.
Actual behavior:
Does not compile.
The text was updated successfully, but these errors were encountered: