2016-04-28 17 views
1

私は、typescriptでintellijを使用してmeteor-angular2アプリケーションを作成しています。タイプMongo.Cursorは一般的ではありません

私は次のコードでRoomInterfaceを作成しました。その後、私は、次のエクスポートされたクラスを持っている

export interface RoomInterface { 
    id:number; 
    name:string; 
} 

export class Rooms extends MeteorComponent{ 
    rooms:Mongo.Cursor<RoomInterface>; 
    constructor() { 
     super(); 
     this.subscribe('rooms',()=>{ 
      this.rooms=RoomsCollection.find(); 
     },true); 
    } 
} 

コードが細かい実行されますがIntelliJのはrooms:Mongo.Cursor<RoomInterface>;

のエラー type Mongo.Cursor is not genericと不平を言っています

何か不足しているのだろうかと思います。

ありがとうございました!

答えて

2

this fileMongo.Cursorの定義は一般的なではないためである。

export interface Cursor extends Readable, NodeJS.EventEmitter { 

それはジェネリックだった場合、それはのようになります。

export interface Cursor<T> extends Readable, NodeJS.EventEmitter { 
     // Use type T in a meaninful way e.g 
     results: T[]; 

クイックフィックス

変更rooms:Mongo.Cursor<RoomInterface>;rooms:Mongo.Cursor;

関連する問題