-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add Event Types #165
Add Event Types #165
Conversation
maybe these should go in the spec so they're upstream? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe these should go in the spec so they're upstream?
There is unfortunately no way to describe these in WebIDL (except for attribute EventHandler onuncapturederror;
).
I actually thought we had this already, but I guess not!
dist/main.d.ts
Outdated
@@ -0,0 +1,16 @@ | |||
import './index.d.ts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically we've been just adding things like this to the top of index.d.ts
:
Lines 5 to 49 in 8faeb6d
// ********************************************************************************************* | |
// Manually-written | |
// ********************************************************************************************* | |
interface HTMLCanvasElement { | |
getContext( | |
contextId: | |
| "webgpu" | |
): GPUCanvasContext | null; | |
} | |
interface OffscreenCanvas { | |
getContext( | |
contextId: | |
| "webgpu" | |
): GPUCanvasContext | null; | |
} | |
// Defined as an empty interface here to prevent errors when using these types in a worker. | |
interface HTMLVideoElement {} | |
type GPUOrigin2DStrict = | |
| Iterable<GPUIntegerCoordinate> | |
| GPUOrigin2DDictStrict; | |
interface GPUOrigin2DDictStrict | |
extends GPUOrigin2DDict { | |
/** @deprecated Does not exist for GPUOrigin2D. */ | |
z?: undefined; | |
} | |
type GPUExtent3DStrict = | |
| Iterable<GPUIntegerCoordinate> | |
| GPUExtent3DDictStrict; | |
// GPUExtent3DDictStrict is defined to help developers catch a common class of errors. | |
// This interface defines depth as an undefined, which will cause a type check failure if someone | |
// attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.) | |
interface GPUExtent3DDictStrict | |
extends GPUExtent3DDict { | |
/** @deprecated The correct name is `depthOrArrayLayers`. */ | |
depth?: undefined; | |
} |
It's probably fine to have multiple files, but we should have all of the additions in one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved what I could.
dist/main.d.ts
Outdated
@@ -0,0 +1,16 @@ | |||
import './index.d.ts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think we should have "index" and "main" as those both denote main files. We could move the existing index.d.ts
to another filename though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved it to types.d.ts
b9454c7
to
fe29865
Compare
note: I separated this into 2 commits. If you look at the commit diffs instead of the PR diff it's easier to see the changes. |
sorry, I'll fix the tests |
This makes addEventListener on GPUDevice have the right type information.
fe29865
to
38a6fff
Compare
ugh. Ok. I just added the types to the original I could not figure out how to separate it into 2 files. The issue was with So, I imported those with
This shut-up TS about undefined types but now it complained So, if we want those separate files we can do that in another PR. For now I just added the changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for looking into splitting it into two files. It's not super important, so if we can't easily figure out how to do it then it's fine if we don't. It also matters less until we have the codegen working better (assuming we ever bother to fix it). |
Just remembered to publish: 0.1.54 |
this makes
addEventListener
onGPUDevice
have the right type information.I wasn't sure how to add it to the generated file.