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
function optional argument parameter mismatch
Playground link with relevant code
function foo(x: number, y: number = 1) { return x + y } type F1 = (x: number) => number type F2 = (x: number, y?: string) => number const f1: F1 = foo const f2: F2 = f1 console.log(f2(1, 'a'))
The code compiles without errors/warnings, despite an obvious type mismatch
Should probably complain when narrowing function type from F1 to F2
The text was updated successfully, but these errors were encountered:
I think this is intentional, as it's equivalent to the (also intentional) type hole that exists with optional properties:
const foo = { x: 777, y: 1206 }; type O1 = { x: number }; type O2 = { x: number, y?: string }; const o1: O1 = foo; const o2: O2 = o1; console.log(o2.y); // oops, not a string
Sorry, something went wrong.
Duplicate of #13043.
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Bug Report
π Search Terms
function optional argument parameter mismatch
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The code compiles without errors/warnings, despite an obvious type mismatch
π Expected behavior
Should probably complain when narrowing function type from F1 to F2
The text was updated successfully, but these errors were encountered: