-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error TS2304: Cannot find name 'WebGL2RenderingContext'. #136
Comments
I still know almost nothing about typescript dev but this sounds like a typescript issue, not a twgl issue. You need to figure out how to include WebGL2 definitions in typescript https://www.npmjs.com/package/@types/webgl2 i don't know if that means something needs to happen here. Maybe someone in this thread knows |
It's a typescript nightmare. By default a user's tsc (typescript compiler) will look at all dependencies and recursively check for unresolved definitions. To disable this behavior and ignore the warnings users have to set their In effect any unresolved dependencies in any typescript library causes (most) users to experience error output. tsc will still output the transpiled javascript. It just spews a bunch of red errors on screen while doing so. For example, my tsconfig.json has the following lines:
When tsc comes across twgl and see's SharedArrayBuffer referenced it throws it's hands up because neither my code or your library have |
So is there something I should add somewhere to make this work? A setting in package.json? A comment in |
@greggman As far as I know the best solution is to feature prominently in the readme that TypeScript users will need to add the aforementioned @types/webgl2 package to their dependencies (or usually just to devDependencies) for WebGL related libraries such as this one to work correctly. The solution is absolutely for sure not maintaining a copy of @types/webgl2 in this package. You could add it to twgl's package dependencies, but that means it ends up in the dependencies of everybody's projects, though the majority of users will not need or want this package to be in their dependencies rather than their devDependencies. And that's if they're using TypeScript at all. Unfortunately there's not currently any way that I can find to programmatically specify that a library's dependants that use TypeScript will need a certain @types package. |
typescript compiler is complaining about the below missing declarations:
Note:
SharedArrayBuffer
is also missing when used in a node.js environmentTo resolve them I had to create the following local definitions:
The text was updated successfully, but these errors were encountered: