Hello! I am seeing an issue when trying to build a project that contains Babylon 6.3.0. Whenever I attempt to build my app, I get the following typescript errors:
../../node_modules/@babylonjs/core/Engines/engine.d.ts(1093,29): error TS2304: Cannot find name 'ImageEncodeOptions'.
../../node_modules/@babylonjs/core/Engines/engine.d.ts(1105,27): error TS2304: Cannot find name 'OffscreenRenderingContextId'.
../../node_modules/@babylonjs/core/Engines/engine.d.ts(1105,72): error TS2304: Cannot find name 'OffscreenRenderingContext'.
Is it possible that some types are missing in the latest releases? I see the same issue with ImageEncodeOptions even in 6.0.0.
This should be in your lib.dom.d.ts provided by typescript. So I guess you might use either a too recent or too old Typescript version. What version are you using ?
there is always a bit of catching us when using the lib-dom declaration of your typescript file. VS Code is using one version, your project is using another version, adn babylon was transpiled using a different version.
TBH - apart from providing our own version of lib.dom, i don’t see a very good way to automatically solve this. There are ways, of course, but they require some steps on the user’s side. This is what I mean when I say it’s not automated.
I’m in the process of updating our Angular solution from version 14 to 15, and I thought I’d try the latest version 6 BabylonJS packages while I was at it. We’ve been on the final version 5 packages for a while now. I’m seeing the same issue with Typescript 4.9.5, which I believe is the highest version that is officially supported by Angular 15.2.x. Maybe it works unofficially, but I don’t think a higher version of Typescript is supported unless we go to Angular 16, which we aren’t planning on doing for a few months.
Updating to typescript 5.0.4 did not fix the problem. Assuming I did that right.
So right now typescript is showing 5.0.4 and babylon is showing 6.4.1
And these are my errors;
[ng] Error: node_modules/@babylonjs/core/Engines/engine.d.ts:1093:29 - error TS2304: Cannot find name ‘ImageEncodeOptions’.
[ng] 1093 convertToBlob(options?: ImageEncodeOptions): Promise;
[ng] ~~~~~~~~~~~~~~~~~~
[ng] Error: node_modules/@babylonjs/core/Engines/engine.d.ts:1105:27 - error TS2552: Cannot find name ‘OffscreenRenderingContextId’. Did you mean ‘OffscreenCanvasRenderingContext2D’?
[ng] 1105 getContext(contextId: OffscreenRenderingContextId, options?: any): OffscreenRenderingContext | null;
[ng] ~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] node_modules/@babylonjs/core/Engines/engine.d.ts:1147:5
[ng] 1147 var OffscreenCanvasRenderingContext2D: {
[ng] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] ‘OffscreenCanvasRenderingContext2D’ is declared here.
[ng] Error: node_modules/@babylonjs/core/Engines/engine.d.ts:1105:72 - error TS2552: Cannot find name ‘OffscreenRenderingContext’. Did you mean ‘OffscreenCanvasRenderingContext2D’?
[ng] 1105 getContext(contextId: OffscreenRenderingContextId, options?: any): OffscreenRenderingContext | null;
[ng] ~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] node_modules/@babylonjs/core/Engines/engine.d.ts:1147:5
[ng] 1147 var OffscreenCanvasRenderingContext2D: {
[ng] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] ‘OffscreenCanvasRenderingContext2D’ is declared here.
[ng] × Failed to compile.
no idea if I am including the ‘dom lib in my tsconfig’ - I use ionic which (usually) handles all the build stuff for me.
This is kind of a massive project (and now the second time in a few months updating babylon has broken some built in types - last time you guys did an update which fixed it)
… time passes - tried to reply but forum stopped me. anyways;
Ok - to “fix” this I did something from the other time I got one of these errors on ‘DOMString’.
I created and included a ‘global.d.ts’ file in my src folder, and then put this in it;
type ImageEncodeOptions = any;
type OffscreenRenderingContextId = any;
type OffscreenRenderingContext = any;
Visual studio complained that this was already declared in lib.dom.d.ts - and red underlined it - but when I ran the project it all compiled and worked correctly.
No idea what this is all about, but at least I can still keep working now…
adding skipLibcheck: true to your compiler options in tsconfig should also solve this, but that’s not the bvest solution, of course.
I am unable to reproduce that, so if it is somehow possible to strip down the problecj and get a barebone package.json, tsconfig, and an index.ts that shows the issue I will be really grateful. And will also be able to understand the issue and (if it is on our end) fix it.
I gave this another try today, it still doesn’t work with the 6.5.0 packages and typescript 4.9.5. Until we upgrade to Angular 16 in a few months, this is the highest version of typescript we can use. We may have to stick with version 5.57.1 for now.
image1079×101 4.58 KB
Our application is massive, I don’t have a good way to give you a simple example you can use for debugging. The best I can do is share our package.json and the relevant settings in tsconfig.json: