-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: 3.9.2
Search Terms:
noImplicitAny true
overloaded
inferred types
Code
I don't know the exact terms for what's happening in the first example. Are these parameters' "types being inferred"?
// `text` has type `string`
window.alert = (text) => {
return window.alert(text);
}
// Both parameters are `any`, because `addEventListener` has overloads
window.addEventListener = (type, fn) => {
return window.addEventListener(type, fn);
}Expected behavior:
They should follow these types from lib.dom.d.ts:
addEventListener<K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;Actual behavior:
Parameter 'type' implicitly has an 'any' type. ts(7006)
Parameter 'fn' implicitly has an 'any' type. ts(7006)
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed