-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
Bug Report
๐ Search Terms
๐ Version & Regression Information
- This is something that I expected to work after 4.3's Contextual Narrowing for Generics
โฏ Playground Link
Playground link with relevant code
๐ป Code
declare const eventType: keyof DocumentEventMap;
document.addEventListener(eventType, (event) => {
event; // Here `event` is `Event | UIEvent | AnimationEvent | MouseEvent | InputEvent | FocusEvent | CompositionEvent | ... 9 more ... | ClipboardEvent
if (eventType === `click`) {
event; // Expected: `event` to be type `MouseEvent`. Actual: It's the union from above.
}
});๐ Actual behavior
Second reference of event is type Event | UIEvent | AnimationEvent | MouseEvent | InputEvent | FocusEvent | CompositionEvent | ... 9 more ... | ClipboardEvent.
๐ Expected behavior
Second reference of event to be of type MouseEvent.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created