Vite + Rollup production build "TS2304: Cannot find name 'WebGLObject'"

Don’t wanna necro the thread but only just came back to Babylon after few months and while updating project dependencies earlier today came across above error.

I want latest Typescript and I want BabylonJS@4.2 but so here is my work around the issue using global type declaration files.

Looking at TypeScript@v4.0.8 source code …

WebGLObject is a very simple interface, so error can be easily avoided by adding highlighted code into type definition files like globals.d.ts (or babylon.d.ts if you have one in your types folder :wink: ). Once BabylonJS@5.0 is out remove the snippet and you will be good to go.

Make sure to have typeRoots prop configured in your tsconfig.json to something like…

{
  "typeRoots": ["node_modules/@types", "src/@types"],
}

Hope it helps.

2 Likes