Getting Uncaught Typeerror: Illegal constructor for using super()

Viewed 112

I'm using Typescript/Javascript and I'm extending the WebGLRenderingContext class and calling super() in the constructor. However, the transpiled code in the browser does not work and the super() in the constructor is highlighted red. Am I supposed to use arguments in super()? What should I do?

Typescript code segment:

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);
  }
}

Transpiled Javascript code:

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", this.onWindowResize, !1)
        }
}
0 Answers
Related