2015-06-11 8 views
6

il codice qui sotto mi porti da transpiling con gulp questo errore:dattiloscritto compilazione errore non può invocare un'espressione il cui tipo manca una firma chiamata

[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); 
     } 
    } 
} 

Qualcuno sa qual è la mia colpa esatto?

La stessa cosa ha funzionato una volta ma dopo alcune modifiche non può più essere compilata.

mio Setup: -Idea 14 -Node.js -Gulp -gulp-TSC -gulp-connect (per Livereload)

risposta

17

ragazzi che hanno lo stesso messaggio di errore -> Controlla la tua Code- Sintassi

Trovato colpa mia. Questo è non 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)]; 
} 

dovrebbe essere:

private getRandomElementOfEnum(e : any):string{ 
     var length:number = Object.keys(e).length; // <--- WITHOUT() 
     return e[Math.floor((Math.random() * length)+1)]; 
    } 
+2

fatto la stessa identica cosa e era seduto lì stairing a questo per circa 20 minuti chiedendo ... – Hector