Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试使用tsc file.ts运行Typescript时出现WebGL2RenderingContext错误_Javascript_Typescript_Npm_Yarnpkg - Fatal编程技术网

Javascript 尝试使用tsc file.ts运行Typescript时出现WebGL2RenderingContext错误

Javascript 尝试使用tsc file.ts运行Typescript时出现WebGL2RenderingContext错误,javascript,typescript,npm,yarnpkg,Javascript,Typescript,Npm,Yarnpkg,我刚刚在Windows 10计算机上使用npm和Thread安装了Typescript,当我运行“tsc file.ts”时,我得到一个错误,上面写着“582 declare var WebGL2RenderingContext” 它指向目录.././AppData/Roaming/npm/node_modules/typescript/lib/lib.dom.d.ts:16485:13 此外,它说16485声明变量WebGL2RenderingContext:{'WebGL2RendingCo

我刚刚在Windows 10计算机上使用npm和Thread安装了Typescript,当我运行“tsc file.ts”时,我得到一个错误,上面写着“582 declare var WebGL2RenderingContext”

它指向目录.././AppData/Roaming/npm/node_modules/typescript/lib/lib.dom.d.ts:16485:13

此外,它说16485声明变量WebGL2RenderingContext:{'WebGL2RendingContext'也在这里声明。发现1个错误

下面是Node.js命令提示符下的screeshot


多亏了Zydnar的帮助,我不可能解决这个问题。经过深思熟虑,我决定注释掉WebGL2呈现函数,它成功了,它被传输到javascript,最后我使用ts node filename.ts运行代码


再次感谢@Zydnar,您帮了大忙。

如果您的声明发生冲突,请尝试导入您需要的声明:

从“webgl2”导入{WebGL2RenderingContext}
const lol=(ctx:WebGL2RenderingContext)=>{/*做某事*/};
对于@types/webgl2,问题是它没有导出,所以您必须对其进行一些更改:
只需在声明关键字之前添加导出即可。

我通过执行这一行解决了这个问题

npm i --save @types/webgl2

但是您没有在服务器端运行WebGL-对吗?
AppData/Roaming/npm/
您已经在全局安装了它-您必须在本地为您的项目安装它。@Zydnar,我必须检查一下,可能我正在运行的其他一些应用程序可能正在使用WebGL,我将尝试在本地安装它…Visual Studio、Chrome和Groove Music同时打开在本地安装typescript后,问题仍然存在:-一种解决方案是使用以下属性从lib.dom.d.ts扩展WebGL2RenderingContext,请记住License注释这是一种不好的做法,在任何依赖项更新后,您都会遇到同样的问题。很好,在使用WebGL2RenderingContext