I'm encountering an error when trying to add a keydown event and convert the parameter type from Event to KeyboardEvent as shown below.
fromEvent(document, "keydown")
.pipe<KeyboardEvent, KeyboardEvent>(
filter((event) => event.code === "F5"),
tap((event) => event.preventDefault())
)
.subscribe((ev) => {
console.log(ev);
});
However, I am getting this error message:
error TS2345: Argument of type 'MonoTypeOperatorFunction<Event>' is not assignable to parameter of type 'OperatorFunction<Event, KeyboardEvent>'.
Type 'Observable<Event>' is not assignable to type 'Observable<KeyboardEvent>'.
Type 'Event' is missing the following properties from type 'KeyboardEvent': altKey, charCode, code, ctrlKey, and 17 more.
Has anyone come across this issue before?