1
votes

I just installed Typescript using both npm and yarn on my Windows 10 machine, and when I run 'tsc file.ts' I get an error that says '582 declare var WebGL2RenderingContext'.

It directs to the directory ../../AppData/Roaming/npm/node_modules/typescript/lib/lib.dom.d.ts:16485:13

Furthermore, It says 16485 declare var WebGL2RenderingContext: { 'WebGL2RendingContext'was also declared here. Found 1 error.

Here is the screeshot from Node.js Command Prompt

enter image description here

3
But you don't run WebGL on server side - right? - Zydnar
AppData/Roaming/npm/ you have installed it global - you have to install it local for your project. - Zydnar
@Zydnar, I'll have to check, maybe some of the other apps I'm running might be using WebGL, I'll try installing it locally... Visual Studio, Chrome and Groove Music are open at the same time - WilliamMabotjaCS227
The problem still persists after installing typescript locally - WilliamMabotjaCS227
Here is all you need: github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/… - one solution would be extend WebGL2RenderingContext from lib.dom.d.ts with following properties, just remember about license - Zydnar

3 Answers

1
votes

If your declarations collide try to import declaration you need:

import {WebGL2RenderingContext} from "webgl2"
const lol = (ctx: WebGL2RenderingContext)=>{/* do sth*/};

with @types/webgl2 problem is it have no exports, so you have to change it a bit: just add export before declare keywords.

1
votes

I resolved this problem executing this line.

npm i --save @types/webgl2
0
votes

I could not have solved this problem without Zydnar's Help, Thanks to Him. After some deliberation, I decided to comment out the WebGL2 Rendering Function and It worked, It transpiled to javascript and I ended up using ts-node filename.ts to run the code.

Thanks once again to @Zydnar, You were very helpful.