-
Notifications
You must be signed in to change notification settings - Fork 441
Introduce Messageable and Transferable for postMessage #534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@saschanaz can you please review. |
How do I add types that sould only be included in |
I couldn't find any way to include different type defs without changing the emitter code. I removed the In the future, we should consider adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO okay for now, but I ultimately would prefer more automatic way as we can detect Transferable
extended attribute from IDL. We may do what we are already doing for createElement
.
inputfiles/overridingTypes.json
Outdated
"postMessage": { | ||
"name": "postMessage", | ||
"override-signatures": [ | ||
"postMessage(message: any, transferList?: Transferable[]): void" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why transferList
instead of transfer
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named it transferList
because it is landed so in the MDN docs.
https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage
I can change it to transfer
if it's preferred.
I'd prefer the automatic way as well, but for now I think this suffices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to transfer
.
This PR addresses microsoft/TypeScript#25176
Relevant MDN pages:
https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel/postMessage
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
https://developer.mozilla.org/en-US/docs/Web/API/Client/postMessage
https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage
https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage
https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/postMessage
Map and Set do not seem to be available in
dom.generated.d.ts
. How would one implement theMessageable
type?