From 16ae4a0d5799c9a4ed776f32929f73b1063ae4e8 Mon Sep 17 00:00:00 2001 From: Leo K Date: Mon, 9 Aug 2021 10:39:00 +0200 Subject: feat(extensions/web): add structuredClone function (#11572) Co-authored-by: Luca Casonato --- extensions/web/lib.deno_web.d.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'extensions/web/lib.deno_web.d.ts') diff --git a/extensions/web/lib.deno_web.d.ts b/extensions/web/lib.deno_web.d.ts index 6c79f61bd..3f110353f 100644 --- a/extensions/web/lib.deno_web.d.ts +++ b/extensions/web/lib.deno_web.d.ts @@ -673,7 +673,15 @@ declare class MessageEvent 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; -- cgit v1.2.3