feat(extensions/web): add structuredClone function (#11572)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Leo K 2021-08-09 10:39:00 +02:00 committed by GitHub
parent 02c74fb709
commit 16ae4a0d57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 107 additions and 36 deletions

View file

@ -673,7 +673,15 @@ declare class MessageEvent<T = any> extends Event {
type Transferable = ArrayBuffer | MessagePort;
interface PostMessageOptions {
/**
* @deprecated
*
* This type has been renamed to StructuredSerializeOptions. Use that type for
* new code.
*/
type PostMessageOptions = StructuredSerializeOptions;
interface StructuredSerializeOptions {
transfer?: Transferable[];
}
@ -710,7 +718,7 @@ declare class MessagePort extends EventTarget {
* objects or port, or if message could not be cloned.
*/
postMessage(message: any, transfer: Transferable[]): void;
postMessage(message: any, options?: PostMessageOptions): void;
postMessage(message: any, options?: StructuredSerializeOptions): void;
/**
* Begins dispatching messages received on the port. This is implictly called
* when assiging a value to `this.onmessage`.
@ -737,3 +745,8 @@ declare class MessagePort extends EventTarget {
options?: boolean | EventListenerOptions,
): void;
}
declare function structuredClone(
value: any,
options?: StructuredSerializeOptions,
): any;