-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed as not planned
Description
Page URL: https://www.typescriptlang.org/docs/handbook/type-inference.html#contextual-typing
Issue:
This is the example to illustrate contextual typing in docs.
However, I don't get desired result in TS playground with this version of code.
window.onmousedown = function (mouseEvent) { // Parameter 'mouseEvent' implicitly has an 'any' type.(7006)
console.log(mouseEvent.button);
console.log(mouseEvent.kangaroo);
};When I change the code above to version below, I get desired result like doc's.
window.addEventListener('mousedown', function(mouseEvent) {
console.log(mouseEvent.button); //<- OK
console.log(mouseEvent.kangaroo); //<- Error!
})I am confused about this. Can someone gives an explanation?
Thanks so much!
Metadata
Metadata
Assignees
Labels
No labels