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

lib.webworker.d.ts doesn't include canvas related types #47752

Closed
LubosD opened this issue Feb 6, 2022 · 4 comments
Closed

lib.webworker.d.ts doesn't include canvas related types #47752

LubosD opened this issue Feb 6, 2022 · 4 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@LubosD
Copy link

LubosD commented Feb 6, 2022

lib Update Request

Configuration Check

My compilation target is ES2015 and my lib is webworker, es2019.

Missing / Incorrect Definition

Canvas-related types, such as CanvasState, are not present in lib.webworker.d.ts in any of the latest releases (4.5.5, 4.6.0-beta etc.). They are only present in lib.dom.d.ts.

This prevents the use of @types/offscreencanvas in webworker sources build.

Somehow confusingly, the missing types are there in your main and release-4.6 (in lib.webworker.d.ts), but not in actual releases in NPM.

Sample Code

Installing @types/offscreencanvas and using "types": ["offscreencanvas"]. No code is needed, because this will fail on its own if webworker lib is used (instead of dom).

Build failure:

Error: node_modules/@types/offscreencanvas/index.d.ts:14:53 - error TS2304: Cannot find name 'CanvasState'.

14 interface OffscreenCanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing,
                                                       ~~~~~~~~~~~


Error: node_modules/@types/offscreencanvas/index.d.ts:14:66 - error TS2304: Cannot find name 'CanvasTransform'.

14 interface OffscreenCanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing,
                                                                    ~~~~~~~~~~~~~~~

Documentation Link

MDN specifically mentions that OffscreenCanvas is available in web workers.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels Feb 7, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Feb 7, 2022
@Josef-Haupt
Copy link

This really is a blocker for anyone using webworkers in combination with offscreencanvas anywhere in the code.

@jtbandes
Copy link
Contributor

Maybe fixed by #51300?

@Swoorup
Copy link

Swoorup commented Apr 21, 2023

Is there a workaround for this?

@jakebailey
Copy link
Member

This was fixed in #51300, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

6 participants