Cannot find name 'OffscreenCanvas' (inside an angular app)
See original GitHub issueHello, I have the same symptoms of this issue: https://github.com/pixijs/pixijs/issues/8174
But the problem isn’t fixed for me yet, and the solution there (installing @types/offscreencanvas) did not help either.
Expected Behavior
Angular app should start even after adding pixi.js.
Current Behavior
Starting the application gives the following error:
Error: node_modules/@pixi/core/index.d.ts:1534:45 - error TS2304: Cannot find name 'OffscreenCanvas'.
1534 static test(source: unknown): source is OffscreenCanvas | HTMLCanvasElement;
~~~~~~~~~~~~~~~
Error: node_modules/@pixi/text/index.d.ts:306:105 - error TS2304: Cannot find name 'OffscreenCanvas'.
306 static measureText(text: string, style: TextStyle, wordWrap?: boolean, canvas?: HTMLCanvasElement | OffscreenCanvas): TextMetrics_2;
~~~~~~~~~~~~~~~
Error: node_modules/@pixi/text/index.d.ts:444:47 - error TS2304: Cannot find name 'OffscreenCanvas'.
444 static get _canvas(): HTMLCanvasElement | OffscreenCanvas;
~~~~~~~~~~~~~~~
Error: node_modules/@pixi/text/index.d.ts:450:55 - error TS2304: Cannot find name 'OffscreenCanvasRenderingContext2D'.
450 static get _context(): CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
Steps to Reproduce
- create an angular app (
ng new my-project
) npm install pixi.js
- call
new Application()
on startup
It is reproduced here: https://github.com/kevincentius/angular-pixi-bug-reproduce
Running npm install
and npm start
should start the project and trigger the error
Environment
- pixi.js 6.3.2
- angular 13.3.0
- Windows 10
Issue Analytics
- State:
- Created a year ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Typescript Cannot find offscreencanvas - Stack Overflow
As per my comment to your question. This seems to be a TypeScript version problem, but the version in your package.json seems to...
Read more >[Solved]-Typescript Cannot find offscreencanvas-three.js
This seems to be a TypeScript version problem, but the version in your package.json seems to be correct. Have you tried to run...
Read more >OffscreenCanvas - Web APIs | MDN
Chrome Edge
OffscreenCanvas Full support. Chrome69. Toggle history Full support. Edge79...
OffscreenCanvas() constructor Full support. Chrome69. Toggle history Full support. Edge79...
contextlost event Full support. Chrome99....
Read more >TypeScript configuration - Angular
The Angular CLI generates a tsconfig.app.json file which is used to build an application, in which the types compiler option is set to...
Read more >cannot find name offscreencanvas, error ts2304
Method 1: Checking if OffscreenCanvas exists: The typeof operator is used to return a string of the type of the operand. The OffscreenCanvas...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Installed packages for pixijs and ng 13.3.7 version:
TWO different ideas that are working for me: 1.
Add type offscreencanvas to tsconfig.app.json:
Add allowSyntheticDefaultImports in compilerOptions in tsconfig.json
OR 2.
In the src folder of angular I´ve added a empty file called typings.d.ts with this content: declare type OffscreenCanvas = any; declare type OffscreenCanvasRenderingContext2D = any;
add this to tsconfig.json
THEN
Add in angular.json
For getting rid of this message: I’ve added allowedCommonJsDependencies: - url
if you have max size warnings you can change them in angular.json
I just tested and found pixi to work on Angular 12, but does not on Angular 13.