8Observer8 Posted January 3, 2017 Share Posted January 3, 2017 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' Quote Link to comment Share on other sites More sharing options...
Théo Sabattié Posted January 3, 2017 Share Posted January 3, 2017 Hi'' You have to cast your htmlElement: this._canvas = <HTMLCanvasElement> yourHtmlElement; this._canvas = yourHtmlElement as HTMLCanvasElement; 8Observer8 and ranagraw 2 Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted January 3, 2017 Author Share Posted January 3, 2017 Thanks very much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.