DEV Community

Discussion on: What problem does Typescript solve ?

Collapse
 
vladi160 profile image
vladi160

Your example is wrong and you don't explain, for what actually is TS. In the first example you will get an error, too - var message = "text"; message('hello');
Uncaught TypeError: message is not a function

Also: function message(text) {console.log(text); return text;}

Collapse
 
ricardopaul profile image
Ricardo Paul

Hey vladi, thank you for your comment. When I say 'the first line of code would work' I refer to the line message.length, because message is declared as a string, the line would actually return message length as opposed to the second line which would fail by trying to call message