如何为该事件提供正确的类型注释?
控制台:
{
originalEvent: InputEvent {isTrusted: true, data: " ", isComposing: false,
inputType: "insertText", dataTransfer: null, …}
value: " "
__proto__: Object
}
打字稿代码:
const InputEvent = (event: ??? ) => console.log(event)
有没有办法将preventdefault函数附加到此?
答案 0 :(得分:0)
InputEvent.ts
文件
export class InputEvent {
isTrusted: boolean;
data: string;
isComposing: boolean;
inputType: string;
dataTransfer: string;
//and whatever more variables you have.
}
您可以这样定义它。
const InputEvent = (event: InputEvent ) => console.log(event);