You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
I was unable to test this on prior versions because _______
⏯ Playground Link
No response
💻 Code
interfaceRegisterFnDepINF{close: Array<()=>void>error: Array<()=>void>message: Array<(msg: string)=>void>open: Array<()=>void>}typeEventType=keyofRegisterFnDepINFclassWebSocketCommunication{
#registerFnDep: RegisterFnDepINF={close: [],error: [],message: [],open: []}$on<TextendsEventType>(type: T,callback: RegisterFnDepINF[T][number]){this.#registerFnDep[type].push(callback)}// errors// Argument of type '(() => void) | (() => void) | ((msg: string) => void) | (() => void)' is not assignable to parameter of type '() => void'.Type '(msg: string) => void' is not assignable to type '() => void'.Target signature provides too few arguments. Expected 1 or more, but got 0.}
🙁 Actual behavior
Argument of type '(() => void) | (() => void) | (() => void) | ((msg: string) => void)' is not assignable to parameter of type '() => void'.
Type '(msg: string) => void' is not assignable to type '() => void'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
You wrongly assume that T extends EventType means that T can only be one specific key, but it can also be a union of keys. This is very known design limitation.
This is an example that demonstrates the problem:
// Passing type "message", but callback without an argument$on<"close"|"message">("message",()=>{})
🔎 Search Terms
ts(2345)
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
🙁 Actual behavior
Argument of type '(() => void) | (() => void) | (() => void) | ((msg: string) => void)' is not assignable to parameter of type '() => void'.
Type '(msg: string) => void' is not assignable to type '() => void'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
🙂 Expected behavior
not error
Additional information about the issue
https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgEoQObAM6SgMRABEIAHASQDl9lkBvAKFoQBsB7bCALmQEEoocAJ4AeABQBKZAF4AfMgBubYABNZTZNChsoPPgOHipcxcrUaAthGzY4GbvsGixF7Bh64ooDMflLV6rRspBAgevxORjJ+ZuoAvgxgQiHIAKIKoWAAKsko0sgA1hBCbDBomDh4hCQU1AyscDbIAOoQAEYAymwIRWAAwmwWFgCuIMAIcGDAbCD0GgDEUBW40NVkPOhYKwTEZFQ0+Yy0x8isHA4A2gC6ADQaJ1o6PNd3J7RWNnaXt-fHwaHPK6-BInAAkMxEWU0AA9ICAVNg0hlwDkQrIxEkQjwsjdTnAWCw2ogCnpNpVVrtavgLlkrhcQMMLG1oFcpEc3mAABY4AB0i2WVUpF0xECuPNIw2wnLEEwJRJ6EmBDDiQA
version: 5.4.5
The text was updated successfully, but these errors were encountered: