8Observer8

[Solved] Type 'HTMLElement' is not assignable to type 'HTMLCanvasElement'

Recommended Posts

Hello,

I decided to use TypeScript with BabylonJS. I learn Getting Started tutorial

I wrote this code:
 

class Game
{
    private _canvas: HTMLCanvasElement;
    private _engine: BABYLON.Engine;
    private _camera: BABYLON.Camera;
    private _scene: BABYLON.Scene;
    private _light: BABYLON.Light;

    constructor(canvasElement: string)
    {
        // Create canvas and engine
        this._canvas = document.getElementById(canvasElement);
        this._engine = new BABYLON.Engine(this._canvas, true);
    }
}

Visual Studio 2015 shows this message:
 

Quote

Error    TS2322    Type 'HTMLElement' is not assignable to type 'HTMLCanvasElement'.
  Property 'height' is missing in type 'HTMLElement'


 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.