2017-11-15 3 views
0

私は甘いアラートライブラリを使用しています:どのように私は私の活字体のエラー解決することができます。プロパティを「を」type「を無効」に存在しません

https://limonte.github.io/sweetalert2/ 

と私はサイトから、次のコードを使用しようとしています:

swal({ 
    title: 'Are you sure?', 
    text: "You won't be able to revert this!", 
    type: 'warning', 
    showCancelButton: true, 
    confirmButtonColor: '#3085d6', 
    cancelButtonColor: '#d33', 
    confirmButtonText: 'Yes, delete it!', 
    cancelButtonText: 'No, cancel!', 
    confirmButtonClass: 'btn btn-success', 
    cancelButtonClass: 'btn btn-danger', 
    buttonsStyling: false 
}).then(function() { 
    swal(
    'Deleted!', 
    'Your file has been deleted.', 
    'success' 
) 
}, function (dismiss) { 
    // dismiss can be 'cancel', 'overlay', 
    // 'close', and 'timer' 
    if (dismiss === 'cancel') { 
    swal(
     'Cancelled', 
     'Your imaginary file is safe :)', 
     'error' 
    ) 
    } 
}) 

私は実行することにより、種類をインストールしました:

npm install --save @types/sweetalert 

が、私はまだ使用に関連して、エラーメッセージを取得しています「then」の:

error TS2339: Property 'then' does not exist on type 'void'. 

どうすれば解決できますか?

答えて

0

あなたの型定義ファイルとあなたのライブラリは合わないと思います。 https://limonte.github.io/sweetalert2/の代わりにhttps://sweetalert.js.org/の.d.tsファイルである@types/sweetalertを取得しました。

SweetAlert2のリポジトリを見ると、ライブラリと同じnpmパッケージにtype definitionsが含まれています。