Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: align some Web API type definitions to lib.dom.d.ts #15219

Merged
merged 3 commits into from
Jul 20, 2022
Merged

chore: align some Web API type definitions to lib.dom.d.ts #15219

merged 3 commits into from
Jul 20, 2022

Conversation

ayame113
Copy link
Contributor

@ayame113 ayame113 commented Jul 16, 2022

Currently, the lib.dom.d.ts type definition and the deno type definition seem to be different for some functions.

The difference I've found is whether the URL is taken as a constructor argument.

example:

URL constructor:

deno/cli/dts/lib.dom.d.ts

Lines 14359 to 14361 in 22a4998

declare var URL: {
prototype: URL;
new(url: string | URL, base?: string | URL): URL;

declare class URL {
constructor(url: string, base?: string | URL);


Request constructor:

deno/cli/dts/lib.dom.d.ts

Lines 11576 to 11578 in 22a4998

declare var Request: {
prototype: Request;
new(input: RequestInfo | URL, init?: RequestInit): Request;

declare class Request implements Body {
constructor(input: RequestInfo, init?: RequestInit);


Response.redirect:

deno/cli/dts/lib.dom.d.ts

Lines 11627 to 11632 in 22a4998

declare var Response: {
prototype: Response;
new(body?: BodyInit | null, init?: ResponseInit): Response;
json(data: unknown, init?: ResponseInit): Response;
error(): Response;
redirect(url: string | URL, status?: number): Response;

declare class Response implements Body {
constructor(body?: BodyInit | null, init?: ResponseInit);
static json(data: unknown, init?: ResponseInit): Response;
static error(): Response;
static redirect(url: string, status?: number): Response;


Websocket constructor:

deno/cli/dts/lib.dom.d.ts

Lines 16581 to 16583 in 22a4998

declare var WebSocket: {
prototype: WebSocket;
new(url: string | URL, protocols?: string | string[]): WebSocket;

declare class WebSocket extends EventTarget {
constructor(url: string, protocols?: string | string[]);

This PR modifies the deno type definition to match lib.dom.d.ts. (similar to #14113)

@crowlKats
Copy link
Member

this was done on purpouse (#14113), as allowing URL in the typings is wrong

@ayame113
Copy link
Contributor Author

ayame113 commented Jul 16, 2022

I saw #14113 and #14769, both seem to be done for the purpose of aligning to lib.dom.d.ts.
And I think the URL in the typing was allowed after #14769.

(Maybe I’m missing something?)

@crowlKats
Copy link
Member

Ah you are right, my bad

@ayame113
Copy link
Contributor Author

No problem, thank you👍

Copy link
Contributor

@ije ije left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@ije ije merged commit 27a72a1 into denoland:main Jul 20, 2022
@ayame113
Copy link
Contributor Author

Thank you for your review!👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants