-
-
Notifications
You must be signed in to change notification settings - Fork 714
Closed
Labels
TypesChanges related to the TypeScript definitionsChanges related to the TypeScript definitionsbugSomething isn't workingSomething isn't working
Description
Bug Description
MessageEvent inherits Event and is supposed to provide the properties of Event such as Event.type and Event.timeStamp to MessageEvent. However, any class inheriting Event (CloseEvent, ErrorEvent & MessageEvent) fails to make any of the base properties accessible and causes the typescript compiler to fail unless MessageEvent type gets replaced by any when trying to access the base event properties.
Reproducible By
The following code is successfully compiled by tsc compiler.
const ws = new WebSocket('ws://localhost:8080');
ws.onmessage = (ev) => {
const e = ev as any;
console.log(e.type);
console.log(e.defaultPrevented);
console.log(e.cancelable);
console.log(e.timeStamp);
};
The following code will throw an error while trying to compile with tsc due to Property '' does not exist on type MessageEvent<any>.
const ws = new WebSocket('ws://localhost:8080');
ws.onmessage = (e) => {
console.log(e.type);
console.log(e.defaultPrevented);
console.log(e.cancelable);
console.log(e.timeStamp);
};
Expected Behavior
Base properties of Event class accessible from inherited classes.
Logs & Screenshots
None
Environment
macOS 15.1 Beta (24B5035e), node v22.6.0, undici v6.19.8
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
TypesChanges related to the TypeScript definitionsChanges related to the TypeScript definitionsbugSomething isn't workingSomething isn't working