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

declare var for WebIDL interface should always have new () #10

Open
Tracked by #99
kainino0x opened this issue Apr 13, 2021 · 0 comments
Open
Tracked by #99

declare var for WebIDL interface should always have new () #10

kainino0x opened this issue Apr 13, 2021 · 0 comments

Comments

@kainino0x
Copy link

declare var for WebIDL interfaces without constructors currently omit the new () definition:

declare var GPUDevice: {
  prototype: GPUDevice;
};

However, this prevents expressions like mydevice instanceof GPUDevice from being valid.
A new () method should be added to the generated var.

Upstream, TypeScript's built-in types would do this:

declare var GPUDevice: {
  prototype: GPUDevice;
  new (): GPUDevice;
};

However, if there is no constructor present in the IDL, then the constructor exists but will always throw. Hence, I think the generator could optionally write:

declare var GPUDevice: {
  prototype: GPUDevice;
  new (): never;
};

to be more precise.

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

No branches or pull requests

1 participant