lib.webworker.d.ts doesn't include canvas related types #47752
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
lib Update Request
Configuration Check
My compilation target is
ES2015
and my lib iswebworker, 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
andrelease-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 ifwebworker
lib is used (instead ofdom
).Build failure:
Documentation Link
MDN specifically mentions that OffscreenCanvas is available in web workers.
The text was updated successfully, but these errors were encountered: