2015-07-20 21 views
1

的任何簽名我有這樣的代碼(修整):打字稿:構建:提供的參數不匹配,調用對象的

class cSubjectSite { 

    collectionHomeMarker: Microsoft.Maps.EntityCollection; 

    showAddressMarker() { 
     var opts: Microsoft.Maps.EntityCollectionOptions = { 
      zIndex: zIndex_HomeMarker, bubble: true, visible: true 
     }; 
    } 
    // Compiler error on this line: 
    this.collectionHomeMarker = new Microsoft.Maps.EntityCollection(opts); 
} 

這對我來說很好。這裏的報關Microsoft.Maps.d.ts:

export interface EntityCollectionOptions { 
    bubble?: boolean; 
    visible?: boolean; 
    zIndex?: number; 
} 

export class EntityCollection implements Entity { 
    EntityCollection(options?: EntityCollectionOptions); 
    // Etc. 

還有我使用(Microsoft.Maps.AdvancedShapes.d.ts)對於具有另一種定義爲EntityCollection擴展功能的第二個聲明文件:

export class EntityCollection implements Entity { 
    constructor(options?: EntityCollectionOptions); 

它看起來像兩個def文件針對不同的ts版本(不同的構造函數語法)?我對def文件不夠了解。

我使用VS 2013與ts 1.5。我確保我的路徑變量和我的proj文件都參考v1.5。我從Nuget獲得了Bing Maps def文件。

我是新來的打字稿,所以我可能會缺少一些基本的東西。

  • 布拉德

回答

0

所以它看起來像一個糟糕的聲明。我改變了Microsoft.Maps.d.ts EntityCollection聲明:

export class EntityCollection implements Entity { 
    constructor(options?: EntityCollectionOptions); 

這顯然是對TS的版本我使用(1.5)正確的語法。

0

微軟沒有發佈針對Bing地圖一個打字稿庫。您在Nuget上找到的那個必須是由某人創建的包裝。不知道誰包裝好。在Bing Maps API中沒有Microsoft.Maps.EntityCollectionOptions類,這只是一個佔位符名稱,您可以在其中放入具有選項的對象。例如:

var opts = { visible: true }; 
var layer = new Microsoft.Maps.EntityCollection(opts); 
+0

def文件來自[DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped)。沒有Microsoft.Maps.EntityCollectionOptions,但有一個[Microsoft.Maps.EntityCollectionOptions對象](https://msdn.microsoft.com/en-us/library/gg427614.aspx),因此def文件包含它用於打字目的。我不知道它的包裝效果如何,這就是爲什麼我將def文件包含在def文件中,以便有人可以看到是否有錯誤。 –

相關問題