-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type declaration of CanvasImageSource in lib.webworker.d.ts is incomplete. #29970
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
Comments
@kazakami and @RyanCavanaugh I'd be happy to contribute to this one! |
I started checking the issue in TSJS lib generator, and exposing For example, Did I get this right? By doing this we would bring dozens of types and interfaces to webworker. |
Any comments anyone? Perhaps @sandersn? |
I'm not an expert on this yet, but the usual reason that you have to add a whole range of types is that a whole spec is missing and needs to be added to idlSource.json. For example, here's the CSS Basic User Interface entry in idlSources.json: {
"url": "https://www.w3.org/TR/css-ui-3/",
"title": "CSS Basic User Interface"
} Is there a w3 (or other?) spec that contains HTMLOrSvgImageElement? Actually, on re-reading the original problem, is it the case that lib.dom.d.ts has these types but lib.webworker.d.ts doesn't? |
Yes, that's the core problem! In the DOM type CanvasImageSource = HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap; And in the Webworker, it is type CanvasImageSource = ImageBitmap; And adding those three missing interfaces to the |
Perhaps we could get a second opinion from @saschanaz ? |
We exclude the non-existent types on workers, so no I tried the example but |
@saschanaz I've tried his example with However, it didn't raise any errors when {
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"lib": [
"es2018",
"dom",
"webworker",
]
}
} (notice that I've placed So my question is, does the order matter here? |
Theoretically yes because the earliest-declared type should be persisted when multiple conflicting types exist. |
Does this solve the problem or do you think that's still a bug? At least doesn't seem to come from TypeScript if I understood correctly. |
Ping @kazakami, please take a look if the above discussion solves your issue (changing the order of items in the lib array), if that can be considered a solution perhaps this issue can be closed. |
Type declaration of CanvasImageSource in lib.webworker.d.ts is now only
ImageBitMap
.But that should be
HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap
https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource
TypeScript Version: 3.4.0-dev.201190216
Search Terms:
CanvasImageSource
Code
tsconfig.json
whole project in https://github.com/Muratam/yabai-sample.ts
Expected behavior:
No error occurs when run
webpack
norwebpack --watch
Actual behavior:
Following error occurs when incremental build in
webpack --watch
"TS2345: Argument of type 'HTMLImageElement' is not assignable to parameter of type 'ImageBitmap'.
Property 'close' is missing in type 'HTMLImageElement' but required in type 'ImageBitmap'"
Playground Link:
Related Issues:
#25468
In that issue, only TypeScript/src/lib/dom.generated.d.ts is referred, but lib.webworker.d.ts is also needed to be referred. Please fix type declaration of CanvasImageSource in lib.webworker.d.ts
The text was updated successfully, but these errors were encountered: