mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -05:00
fix: Worker accepts specifier as URL (#11038)
This commit updates type declarations for Worker to accept specifiers as either strings or URL, bringing it in line with TypeScript declarations and browser behavior.
This commit is contained in:
parent
0cbaeca026
commit
a8e4fc15e5
2 changed files with 7 additions and 7 deletions
2
cli/dts/lib.deno.shared_globals.d.ts
vendored
2
cli/dts/lib.deno.shared_globals.d.ts
vendored
|
@ -405,7 +405,7 @@ declare class Worker extends EventTarget {
|
|||
onmessage?: (e: MessageEvent) => void;
|
||||
onmessageerror?: (e: MessageEvent) => void;
|
||||
constructor(
|
||||
specifier: string,
|
||||
specifier: string | URL,
|
||||
options?: WorkerOptions,
|
||||
);
|
||||
postMessage(message: any, transfer: ArrayBuffer[]): void;
|
||||
|
|
|
@ -161,7 +161,7 @@ Deno.test({
|
|||
const promise = deferred();
|
||||
|
||||
const busyWorker = new Worker(
|
||||
new URL("busy_worker.js", import.meta.url).href,
|
||||
new URL("busy_worker.js", import.meta.url),
|
||||
{ type: "module" },
|
||||
);
|
||||
|
||||
|
@ -194,7 +194,7 @@ Deno.test({
|
|||
const promise = deferred();
|
||||
|
||||
const racyWorker = new Worker(
|
||||
new URL("racy_worker.js", import.meta.url).href,
|
||||
new URL("racy_worker.js", import.meta.url),
|
||||
{ type: "module" },
|
||||
);
|
||||
|
||||
|
@ -219,7 +219,7 @@ Deno.test({
|
|||
const promise2 = deferred();
|
||||
|
||||
const worker = new Worker(
|
||||
new URL("event_worker.js", import.meta.url).href,
|
||||
new URL("event_worker.js", import.meta.url),
|
||||
{ type: "module" },
|
||||
);
|
||||
|
||||
|
@ -263,7 +263,7 @@ Deno.test({
|
|||
const promise1 = deferred();
|
||||
|
||||
const worker = new Worker(
|
||||
new URL("event_worker_scope.js", import.meta.url).href,
|
||||
new URL("event_worker_scope.js", import.meta.url),
|
||||
{ type: "module" },
|
||||
);
|
||||
|
||||
|
@ -292,11 +292,11 @@ Deno.test({
|
|||
const promise2 = deferred();
|
||||
|
||||
const regularWorker = new Worker(
|
||||
new URL("non_deno_worker.js", import.meta.url).href,
|
||||
new URL("non_deno_worker.js", import.meta.url),
|
||||
{ type: "module" },
|
||||
);
|
||||
const denoWorker = new Worker(
|
||||
new URL("deno_worker.ts", import.meta.url).href,
|
||||
new URL("deno_worker.ts", import.meta.url),
|
||||
{
|
||||
type: "module",
|
||||
deno: {
|
||||
|
|
Loading…
Reference in a new issue