0

Visual Studio 2015 Professional Update 2を実行していて、クライアントのシステム用のソリューションを構築するときに定期的にTypeScriptエラーが発生します。特定のエラーは、次のとおりです。jQueryUI documentation for autocompleteVS2015のjQueryUI AutoCompleteでのTypeScriptエラー

TS2345 Argument of type 
    '{ 
     source: (req: any, resp: any) => void; 
     focus: (event: any, ui: any) => void; 
     minLength: number; 
     ...' 
    is not assignable to parameter of type 'AutocompleteOptions'. 
    Object literal may only specify known properties, and 'focus' does not exist 
    in type 'AutocompleteOptions'. 

見た、これは正当なように見えます。次のように

init()関数内から)このエラーの原因となったコードの断片である:

$(lookupElem).autocomplete({ 
    source: (req, resp) => this.onAutoCompleteRequest(req, resp), 
    focus: (event, ui) => { 
     // Don't populate input field with selected value (pxid) 
     event.preventDefault(); 
    }, 
    minLength: 3, // Don't call autocomplete until specified number of characters have been input 
    select: (e, ui) => this.onItemSelected(e, ui) 
}); 

これはVS2013で働いているので、私はVS2015は、問題を抱えている理由はわかりません。これにより、ソリューションの残りの部分(Azureコンポーネント、別のMVC Webサイトなど)がビルドに失敗し、既存の.js.js.mapファイルがソースフォルダから削除されています。

  • は、この問題を解決;:私のどちらかができますか

    または

  • Visual Studioから完全にこのエラーを抑制しますか?活字ツールの

私のバージョンは、最新のツール=>拡張機能と更新内からのように見える1.8.24.0、です。

多くのありがとうございます。

答えて

0

これはVS2013で働いているので、私はVS2015は、これが原因で活字体でfreshnessの新機能である問題

を持っている理由はわからない:https://basarat.gitbooks.io/typescript/content/docs/types/freshness.html

クイックフィックス

ただ変数に移動:

const config = { 
    source: (req, resp) => this.onAutoCompleteRequest(req, resp), 
    focus: (event, ui) => { 
     // Don't populate input field with selected value (pxid) 
     event.preventDefault(); 
    }, 
    minLength: 3, // Don't call autocomplete until specified number of characters have been input 
    select: (e, ui) => this.onItemSelected(e, ui) 

}; 
$(lookupElem).autocomplete(config); 

より良い修正

に間違いにPRを送るグレート

+0

を入力した、それが働いた - そのためのおかげで!あなたは "より良い修正"を明確にしていただけますか?新鮮な記事に基づいて、 '[x:string]:any'をインクルードするautoCompleteオプションのためのTypeScript型バインディングが必要であり、オプションのプロパティが許可されると思います。 –

+0

@d_mcg no。 'complete'メソッドが受け入れる型に' focus:any'を追加する必要があります – basarat

関連する問題