0
最近サポートされていないNuGetパッケージを置き換えるためにNPMの型を使用するようにアップグレードしました。正常に動作するために使用次のコード:プロパティxがタイプに存在しません。機能
interface Function
{
/** Creates a function that calls the specified function using the specified "this" pointer. Useful in scenarios where we need to pass a function as a callback, but specifying the value of "this".*/
defer(thisArg: Object): Function;
}
Function.prototype.defer = function (thisArg: Object)
{
var self = this;
//return a function that calls the current function with the specific this argument
return function()
{
self.call(thisArg)
};
}
しかし、今、私はエラー私はインターフェイスでそれを指定していますので、プロパティが存在するProperty 'defer' does not exist on type 'Function'.
を取得していますが、コンパイラまだ不平を言っている。これをどうやって解決するのですか?
ない答えが、これはどのような[ 'bind'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)ではありませんありますか? –
javascriptの出力を見て、 'defer'関数を使用するコードが定義の後に出力されていることを確認してください。ファイルが間違った順序で出力されている場合は、定義の前に使用され、エラーが発生します。 –