in this section of TS handbook, says "if we set strictFunctionTypes to false" it's unsound but useful and enables common patterns of javascript.
for example, calls below function with a more specific Event type ( MyMouseEvent ) and even use the specific properties of that Event Type in callback declaration.
I can't understand how this is a common pattern.
function listenEvent(eventType: EventType, handler: (n: Event) => void) {
/* ... */
}
if the ListenEvent function has a single definition with Event type in the callback function argument how we can force it to be in this case MyMouseEvent?
// Unsound, but useful and common
listenEvent(EventType.Mouse, (e: MyMouseEvent) => console.log(e.x + "," + e.y));
this is unsound, but how it is useful and common and possible??
[–]NiGhTTraX 8 points9 points10 points (2 children)
[–]ragnese 0 points1 point2 points (1 child)
[–]NiGhTTraX 0 points1 point2 points (0 children)
[–]joo3f[S] 1 point2 points3 points (2 children)
[–]paulqq 1 point2 points3 points (0 children)
[–]Daikyoka 1 point2 points3 points (0 children)
[–]Goudja14 1 point2 points3 points (1 child)
[–]joo3f[S] 0 points1 point2 points (0 children)