Skip to content

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

Closed
@LubosD

Description

@LubosD

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions