2017-09-22 75 views
1

我有我轉換爲打字稿的項目。我已經下載了最新的@types和我試圖創建一個custom.d.ts文件。該文件看起來像這樣至今:打字稿定製d.ts文件

/// <reference path="../../../node_modules/@types/jquery/index.d.ts"/> 

interface jQuery{ 
    iCheck(): JQuery; 
    bootstrapSwitch(): JQuery; 
} 

interface jQueryStatic{ 
    notific8(): JQuery; 
} 

declare var notific8: JQueryStatic; 
declare var isCheck: JQuery; 
declare var bootstrapSwitch: JQuery; 

在我的文件,我想使用的定義,我讓使用

/// <reference path="../utility/custom.d.ts" /> 

Visual Studio中對它的引用承認的路徑是正確的,但當我將鼠標懸停在實現它的代碼我得到:

[ts] Property 'notific8' does not exist on type 'JQueryStatic<HTMLElement>' 

[ts] Property 'iCheck' does not exist on type 'JQuery<HTMLElement>'. 
[ts] Property 'bootstrapSwitch' does not exist on type 'JQuery<HTMLElement>'. 

我用盡了申報線移動到應用程序文件,但我仍然得到同樣的錯誤?有人知道爲什麼Typescript不承認它嗎?我使用的打字稿2.5.2和 「@類型/ jQuery的」: 「^ 3.2.12」 謝謝。

回答

0

的問題可能是,因爲你的類型JQuery,不jQuery變量。

同樣適用於JQueryStatic(應爲jQueryStatic打字稿識別notific8屬性)

相關問題