vincent15000's avatar

Typescript const becomes var ?

Hello,

I don't know Typescript at all and I just saw the first video of the Laracasts Typescript serie and something seems strange.

When the developer declares a constant const name: string = "Carol";, the typescript compiler changes the constant to a variable var name = "Carol"; ?

Hmmm ... I try to understand why ... if the developer chooses a constant, there is a reason ... the code shoudn't be changed by the typescript compiler.

Or perhaps I don't have understood exactly what happens ?

Thanks for your answers.

V

0 likes
1 reply
jlrdw's avatar
jlrdw
Best Answer
Level 75

It's compiled to javascript. Probably an earlier version for compatibility.

1 like

Please or to participate in this conversation.