Skip to content

Commit 33d0b25

Browse files
committed
add URL typing to webworker
URL is also available in workder. <https://url.spec.whatwg.org/#idl-index>
1 parent c882947 commit 33d0b25

File tree

3 files changed

+120
-1
lines changed

3 files changed

+120
-1
lines changed

baselines/dom.generated.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13232,6 +13232,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
1323213232
readonly top: Window;
1323313233
readonly window: Window;
1323413234
URL: typeof URL;
13235+
URLSearchParams: typeof URLSearchParams;
1323513236
Blob: typeof Blob;
1323613237
customElements: CustomElementRegistry;
1323713238
alert(message?: any): void;
@@ -13858,6 +13859,25 @@ interface ImageBitmap {
1385813859
close(): void;
1385913860
}
1386013861

13862+
interface URL {
13863+
href: string;
13864+
readonly origin: string;
13865+
protocol: string;
13866+
username: string;
13867+
password: string;
13868+
host: string;
13869+
hostname: string;
13870+
port: string;
13871+
pathname: string;
13872+
search: string;
13873+
toJSON(): string;
13874+
}
13875+
13876+
declare var URL: {
13877+
prototype: URL;
13878+
new (url: string, base?: string): URL;
13879+
}
13880+
1386113881
interface URLSearchParams {
1386213882
/**
1386313883
* Appends a specified key/value pair as a new search parameter.

baselines/webworker.generated.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,8 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo
14061406
onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any;
14071407
readonly performance: Performance;
14081408
readonly self: WorkerGlobalScope;
1409+
URL: typeof URL;
1410+
URLSearchParams: typeof URLSearchParams;
14091411
msWriteProfilerMark(profilerMarkName: string): void;
14101412
createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
14111413
createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
@@ -1484,6 +1486,25 @@ interface ImageBitmap {
14841486
close(): void;
14851487
}
14861488

1489+
interface URL {
1490+
href: string;
1491+
readonly origin: string;
1492+
protocol: string;
1493+
username: string;
1494+
password: string;
1495+
host: string;
1496+
hostname: string;
1497+
port: string;
1498+
pathname: string;
1499+
search: string;
1500+
toJSON(): string;
1501+
}
1502+
1503+
declare var URL: {
1504+
prototype: URL;
1505+
new (url: string, base?: string): URL;
1506+
}
1507+
14871508
interface BlobPropertyBag {
14881509
type?: string;
14891510
endings?: string;

inputfiles/addedTypes.json

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,67 @@
178178
"name": "multiEntry",
179179
"type": "boolean"
180180
},
181+
{
182+
"kind": "interface",
183+
"name": "URL",
184+
"flavor": "Worker",
185+
"constructorSignatures": [
186+
"new (url: string, base?: string): URL"
187+
],
188+
"properties": [
189+
{
190+
"name": "href",
191+
"type": "string"
192+
},
193+
{
194+
"name": "origin",
195+
"type": "string",
196+
"readonly": true
197+
},
198+
{
199+
"name": "protocol",
200+
"type": "string"
201+
},
202+
{
203+
"name": "username",
204+
"type": "string"
205+
},
206+
{
207+
"name": "password",
208+
"type": "string"
209+
},
210+
{
211+
"name": "host",
212+
"type": "string"
213+
},
214+
{
215+
"name": "hostname",
216+
"type": "string"
217+
},
218+
{
219+
"name": "port",
220+
"type": "string"
221+
},
222+
{
223+
"name": "pathname",
224+
"type": "string"
225+
},
226+
{
227+
"name": "search",
228+
"type": "string"
229+
}
230+
],
231+
"methods": [
232+
{
233+
"name": "toJSON",
234+
"signatures": ["toJSON(): string"]
235+
}
236+
]
237+
},
181238
{
182239
"kind": "interface",
183240
"name": "URLSearchParams",
184-
"flavor": "Web",
241+
"flavor": "All",
185242
"constructorSignatures": [
186243
"new (init?: string | URLSearchParams): URLSearchParams"
187244
],
@@ -226,6 +283,27 @@
226283
"name": "URL",
227284
"type": "typeof URL"
228285
},
286+
{
287+
"kind": "property",
288+
"interface": "WorkerGlobalScope",
289+
"exposeGlobally": false,
290+
"name": "URL",
291+
"type": "typeof URL"
292+
},
293+
{
294+
"kind": "property",
295+
"interface": "Window",
296+
"exposeGlobally": false,
297+
"name": "URLSearchParams",
298+
"type": "typeof URLSearchParams"
299+
},
300+
{
301+
"kind": "property",
302+
"interface": "WorkerGlobalScope",
303+
"exposeGlobally": false,
304+
"name": "URLSearchParams",
305+
"type": "typeof URLSearchParams"
306+
},
229307
{
230308
"kind": "property",
231309
"interface": "Window",

0 commit comments

Comments
 (0)