如何解决获取未捕获的类型错误:使用 super() 的构造函数非法
我正在使用 Typescript/Javascript,我正在扩展 WebGLRenderingContext 类并在构造函数中调用 super()。但是,浏览器中转译的代码不起作用,构造函数中的 super() 以红色突出显示。我应该在 super() 中使用参数吗?我该怎么办?
打字稿代码段:
export abstract class ShaderCore extends WebGLRenderingContext {
public constructor() {
super();
//Create our program.
this.shaderProgram = <WebGLProgram>this.createProgram();
//Initialise buffer.
this.positionBuffer = <WebGLBuffer>this.createBuffer();
this.bindBuffer(this.ARRAY_BUFFER,this.positionBuffer);
//Add eventlistener so that we can resize canvas when window is resized.
window.addEventListener('resize',this.onWindowResize,false);
}
}
转译的 Javascript 代码:
class o extends WebGLRenderingContext {
constructor() {
super(),//Highlighted line
this.positions = new i.VertexPositions,this.shaderProgram = this.createProgram(),this.positionBuffer = this.createBuffer(),this.bindBuffer(this.ARRAY_BUFFER,this.positionBuffer),window.addEventListener("resize",!1)
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。