-
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
Errors when using types with a web worker. #151
Comments
huh, on that issue @toji was wondering why only HTMLVideoElement was a problem and nothing else. Wonder what the difference in config is. The workaround would be fine for now but it's not the best, I'd like to be able to conditionally define some things only if DOM types are available. Like: type IfDOM<T> = ('document' in typeof globalThis) ? T : never;
type GPUImageCopyExternalImageSource =
| ImageBitmap
| ImageData
| IfDOM<HTMLImageElement>
| IfDOM<HTMLVideoElement>
| VideoFrame
| IfDOM<HTMLCanvasElement>
| OffscreenCanvas; but that is not actually valid syntax. I'm sure something like that is possible though. |
Is there any way to provide multiple .d.ts files instead of just single index? Lets say worker.d.ts will provide types for a worker etc. I am not sure how that would be configured in tsconfig though. |
I don't know. I tried looking it up yesterday, but couldn't find anything. But I think the idea I had would work if I could think of the syntax. I believe that TypeScript's builtin types for |
type GetTypeIfConstructorDeclared<Name extends string> =
typeof globalThis extends { [k in Name]: { prototype: infer T } } ? T : never;
type x = GetTypeIfConstructorDeclared<'HTMLImageElement'>; // x == HTMLImageElement
type y = GetTypeIfConstructorDeclared<'ThingThatDoesNotExist'>; // y == never |
Following similar issue to #114 , I am getting:
Following change ( similar to https://github.com/gpuweb/types/pull/115/files ) would fix the build error
The text was updated successfully, but these errors were encountered: