2015-06-11 5 views
6

नीचे कोड घूंट के साथ यह इस त्रुटि transpiling से मुझे मिल आह्वान नहीं कर सकता:टाइपप्रति संकलन त्रुटि एक अभिव्यक्ति है जिसका प्रकार का अभाव एक कॉल हस्ताक्षर

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

किसी को भी पता है मेरे सटीक गलती है क्या?

वही बात एक बार काम करती है लेकिन कुछ बदलावों के बाद यह अब संकलित नहीं हो सकती है।

मेरे सेटअप: -IDEA 14 -Node.js -Gulp -gulp-tsc (Livereload के लिए) -gulp कनेक्ट

उत्तर

17

दोस्तों, जो एक ही त्रुटि संदेश है -> चेक अपने Code- सिंटेक्स

मेरी गलती मिली। यह जावा नहीं है।

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

होना चाहिए:

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

ठीक उसी काम किया है और वहां बैठ गया था के बारे में 20 मिनट के लिए सोच इसे stairing ... – Hector

संबंधित मुद्दे