Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  105] [ 3]  / answers: 1 / hits: 35455  / 6 Years ago, wed, february 7, 2018, 12:00:00

I am new to Angular, and as you know to be a good Angular developer you have to be good in typescript, so I wrote my simple program as you can see :



function loge(messag){
console.log(messag);
}

var message:string;

message = Hi;

loge(message);


There is no Syntax error I believe But I get this in my Terminal :



SyntaxError: Unexpected token :
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3


I don't know why I get this, I need to help so I can move on.
I am using the version 2.5.3 of typescript and PhpStrom as an IDE.



Any help would be much appreciated.


More From » angular

 Answers
10

Type annotations don't exist in JavaScript, so this line:



var message:string;


Should be:



var message


Remember to transpile your TypeScript to JavaScript - and reference the JavaScript file in your application.


[#55228] Monday, February 5, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harrisonnelsonb

Total Points: 63
Total Questions: 112
Total Answers: 97

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;