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
const test3 = (cb: (arg1: string) => void) => {
cb("test")
}
const test2 = (cb: () => void) => {
test3(cb)
}
const test = () => {
test2((val?: number) => {
console.log(typeof val) // Expect number but it prints string
})
}
test()
🙁 Actual behavior
This type checks just fine and prints out "string"
🙂 Expected behavior
This should fail somehow because it is unsound. I'm not sure where it should fail and maybe this is just an accepted bug, but if that is the case then the FAQ should be updated to reflect that you can make unsound behavior by implicitly casting functions with optional parameters.