1
0
Fork 0
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:
Bartek Iwańczuk 2021-06-18 21:34:51 +02:00 committed by GitHub
parent 0cbaeca026
commit a8e4fc15e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -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;

View file

@ -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: {