Skip to content

"let" keyword doesn't work sometimes. #2

@selimrecep

Description

@selimrecep

Hi, "let" keyword doesn't work when i using <HTMLCanvasElement>
Input:

 "use strict"; 

var canvas: HTMLCanvasElement = <HTMLCanvasElement>document.getElementById("game"); // Problem
var ctx = canvas.getContext("2d");
/*function kare(ctx) {
    this.x = 0;
    this.y = 0;
    this.w = 0;
    this.h = 0;
    this.draw = function () {

    }
}*/
function image(){
    this.x = 0;
}
let a: number = 1; // Problem
alert(a);

Output:

//Compiled TypeScript

"use strict";
var canvas = document.getElementById("game");
var ctx = canvas.getContext("2d");
function image() {
    this.x = 0;
}
let;
a:
number = 1
alert(a);


Input:

"use strict";

// Deleted line
var ctx = canvas.getContext("2d");
/*function kare(ctx) {
    this.x = 0;
    this.y = 0;
    this.w = 0;
    this.h = 0;
    this.draw = function () {

    }
}*/
function image(){
    this.x = 0;
}
let a: number = 1; // Working good
alert(a);

Output:

//Compiled TypeScript

"use strict";
var ctx = canvas.getContext("2d");
/*function kare(ctx) {
    this.x = 0;
    this.y = 0;
    this.w = 0;
    this.h = 0;
    this.draw = function () {

    }
}*/
function image() {
    this.x = 0;
}
var a = 1; // Working good
alert(a);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions