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.5.0
Code
const a: (d: string) => number = (d) => d.length; const b: (d?: string) => number = a; b();
Expected behavior: When compiled with --strict, the assignment of b should cause a type error along the lines of:
--strict
b
string | undefined is not assignable to type string.
string | undefined
string
Actual behavior: The code compiles with --strict, then throws an exception at runtime on the expression d.length.
d.length
The text was updated successfully, but these errors were encountered:
Unfortunately that's expected behaviour: FAQ - Why are function parameters bivariant.
Sorry, something went wrong.
Thank you. This is disappointing, but I understand the reasons.
No branches or pull requests
TypeScript Version: 2.5.0
Code
Expected behavior:
When compiled with
--strict
, the assignment ofb
should cause a type error along the lines of:Actual behavior:
The code compiles with
--strict
, then throws an exception at runtime on the expressiond.length
.The text was updated successfully, but these errors were encountered: