Skip to content

'void' parameters treated as optional only for calls, but not for assignability. #40227

New issue

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

Closed
rbuckton opened this issue Aug 24, 2020 · 1 comment · Fixed by #40231
Closed

'void' parameters treated as optional only for calls, but not for assignability. #40227

rbuckton opened this issue Aug 24, 2020 · 1 comment · Fixed by #40231

Comments

@rbuckton
Copy link
Contributor

rbuckton commented Aug 24, 2020

TypeScript Version: 4.0.2

Search Terms: signature void parameter optional assignability

Code

declare function f(a: number, b?: void): void;
declare function g(a: number, b: void): void;
f(1); // ok
g(1); // ok

let ff: (a: number) => void = f; // ok
let gg: (a: number) => void = g; // error

Expected behavior:

g should be assignable to gg since we treat void parameters as optional.

Actual behavior:

g is not assignable to gg.

Playground Link: link

Related Issues: #39817, #29131

@ExE-Boss
Copy link
Contributor

Also Related Issues: #29131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants