私は、($ event.targetを使用して)要素を入力として取るmodalWindowを起動するメソッドを持っています。私は入力の種類のチェックを実行しようとしているが、チェックは常に要素が数字でないとしても扱います。要素が数字かどうかはconsole.logが出力され、elseは決して実行されません。タイプガードを使用したタイプスクリプトのチェック
launchModal(element: number | any) {
if (<number>element) {
console.log('ele as num', element);
} else {
const elementId = (event.target as Element).id;
const elementIdArray = String(elementId).split('-');
this.currentRow = parseInt(elementIdArray[2], 10);
}
this.loadEquipmentFullRowDataRequest(this.currentRow);
}
私はtypescriptですでofficial site