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
"ts2554", "optional parameter", "overloads"
https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgKIDcLgLJwA7IDeAUMsnAFzIgCuAtgEbQDcpyDV6A9sACasBfYsV4QEAGzhQUMGiARhgXEMl7AAznjhgEACwA8AaWQQAHpBC91yANYQAnlxhpMOfAD4AFGHt4IVQwAaZDApAHMIMCoMLDBcPABtQwBdAEpOHn4RDS0dXU8AcjgC4IBGACYAZlTWNU1tPUKGAprkAHo2tFM-BQheZHLyKDD6WPVghhowZDCuadKAOk9ygFYVgBZU5ABBFXDR8GQYLihkAtDhyILkAHc4axA55DwoLnQ+PuEfP2QAVRAlCAACpcACS4Gg6jEimU+l+7mQAF42J5fiZzFgrOQQPZkAB+ZCeUxUX5bREI7h8ZBUEAQTBQLZmCxYzxEqigGDQZCgskUzJbAmg6nUOnQYjfFAAERyDQMxkRtgcThcsXiCIV-0BIPBkCgUIUgKM6OZ1jsjmcMTcBAJ3l8-mQQRC4Ui0VccXwSTSSL5VJpoqg7lqYkk0mQCGU6mmdVyenKVGl9TytRleXKhWKZSqNWyidjTRazHanS4NmIQA
interface EventMap { a: number; b: void; } declare function dispatch<K extends keyof EventMap>(type: K, target: EventMap[K]): void; dispatch('a', 123); dispatch('b'); // Expected 2 arguments, but got 1.(2554) An argument for 'target' was not provided type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never type Dispatch<K = keyof EventMap> = UnionToIntersection<K extends keyof EventMap ? (type: K, target: EventMap[K]) => void : never>; declare const dispatch2: Dispatch; dispatch2('a', 123); dispatch2('b'); // ok
Errors in code Expected 2 arguments, but got 1.
No Errors
dispatch('b') matches the signature function dispatch<"b">(type: "b", target: void): void but still raises an error.
dispatch('b')
function dispatch<"b">(type: "b", target: void): void
I tried use overloads as a work around, and that just works. So is this is a bug or intentional?
The text was updated successfully, but these errors were encountered:
duplicate #29131
Sorry, something went wrong.
No branches or pull requests
🔎 Search Terms
"ts2554", "optional parameter", "overloads"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgKIDcLgLJwA7IDeAUMsnAFzIgCuAtgEbQDcpyDV6A9sACasBfYsV4QEAGzhQUMGiARhgXEMl7AAznjhgEACwA8AaWQQAHpBC91yANYQAnlxhpMOfAD4AFGHt4IVQwAaZDApAHMIMCoMLDBcPABtQwBdAEpOHn4RDS0dXU8AcjgC4IBGACYAZlTWNU1tPUKGAprkAHo2tFM-BQheZHLyKDD6WPVghhowZDCuadKAOk9ygFYVgBZU5ABBFXDR8GQYLihkAtDhyILkAHc4axA55DwoLnQ+PuEfP2QAVRAlCAACpcACS4Gg6jEimU+l+7mQAF42J5fiZzFgrOQQPZkAB+ZCeUxUX5bREI7h8ZBUEAQTBQLZmCxYzxEqigGDQZCgskUzJbAmg6nUOnQYjfFAAERyDQMxkRtgcThcsXiCIV-0BIPBkCgUIUgKM6OZ1jsjmcMTcBAJ3l8-mQQRC4Ui0VccXwSTSSL5VJpoqg7lqYkk0mQCGU6mmdVyenKVGl9TytRleXKhWKZSqNWyidjTRazHanS4NmIQA
💻 Code
🙁 Actual behavior
Errors in code
Expected 2 arguments, but got 1.
🙂 Expected behavior
No Errors
Additional information about the issue
dispatch('b')
matches the signaturefunction dispatch<"b">(type: "b", target: void): void
but still raises an error.I tried use overloads as a work around, and that just works. So is this is a bug or intentional?
The text was updated successfully, but these errors were encountered: