the code below get me by transpiling it with gulp this error:
[tsc] > C:/Workarea/MyFirstAngular/src/enum/msg.ts(35,33): error TS2349: Cannot invoke an expression whose type lacks a call signature. Failed to compile TypeScript: Error: tsc command has exited with code:2
module MessageUtil {
enum Morning {
"Good Morning",
"Great to see you!",
"Good day.",
"Lovely day today, isn't it?",
"What's up?",
"Nice to meet you",
}
}
export class MessageData {
private getRandomElementOfEnum(e : any):string{
var length:number = Object.keys(e).length(); //<-- This is Line 35
return e[Math.floor((Math.random() * length)+1)];
}
public getRandMorning():string {
return this.getRandomElementOfEnum(Morning);
}
}
}
Does anybody know what's my exact fault?
My Setup: -IDEA 14 -Node.js -Gulp -gulp-tsc -gulp-connect (for Livereload)
Guys who have same error message --> Check your Code-Syntax
Found my fault. This is not Java.
private getRandomElementOfEnum(e : any):string{ var length:number = Object.keys(e).length(); //<-- This is Line 35 return e[Math.floor((Math.random() * length)+1)]; }
Should be:
private getRandomElementOfEnum(e : any):string{
var length:number = Object.keys(e).length; // <--- WITHOUT ()
return e[Math.floor((Math.random() * length)+1)];
}