|
|
|
|
|
by ivxvm
1801 days ago
|
|
I've never seen people pulling those "wacky" functions out of thin air on a whim. I usually see them rarely arising in places where they make sense. Like event subscriptions. For example, in
window.addEventListener("click", callback)
callback is a procedure that receives MouseEvent,
while in
window.addEventListener("copy", callback)
callback is a procedure that receives ClipboardEvent.
So we can say that type of second argument depends on the string passed as first.
TypeScripts type system is able to make this statically typed and type checked properly. Any examples of "wacky" functions where similar dependencies exist but are not necessary? |
|
BTW, just for the record I didn't mention above, but I do love what many languages are doing such as TypeScript where strong typing can be gradually added over time.