summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/web/lib.deno_web.d.ts6
-rw-r--r--tests/unit/structured_clone_test.ts9
2 files changed, 9 insertions, 6 deletions
diff --git a/ext/web/lib.deno_web.d.ts b/ext/web/lib.deno_web.d.ts
index d28e33f58..3ebc9af49 100644
--- a/ext/web/lib.deno_web.d.ts
+++ b/ext/web/lib.deno_web.d.ts
@@ -1124,10 +1124,10 @@ declare var MessagePort: {
*
* @category DOM APIs
*/
-declare function structuredClone(
- value: any,
+declare function structuredClone<T = any>(
+ value: T,
options?: StructuredSerializeOptions,
-): any;
+): T;
/**
* An API for compressing a stream of data.
diff --git a/tests/unit/structured_clone_test.ts b/tests/unit/structured_clone_test.ts
index 314a276dd..6e0473f9a 100644
--- a/tests/unit/structured_clone_test.ts
+++ b/tests/unit/structured_clone_test.ts
@@ -9,9 +9,12 @@ Deno.test("self.structuredClone", async () => {
const arrayOriginal = ["hello world"];
const channelOriginal = new MessageChannel();
const [arrayCloned, portTransferred] = self
- .structuredClone([arrayOriginal, channelOriginal.port2], {
- transfer: [channelOriginal.port2],
- });
+ .structuredClone(
+ [arrayOriginal, channelOriginal.port2] as [string[], MessagePort],
+ {
+ transfer: [channelOriginal.port2],
+ },
+ );
assert(arrayOriginal !== arrayCloned); // not the same identity
assertEquals(arrayCloned, arrayOriginal); // but same value
channelOriginal.port1.postMessage("1");