Recently, I came across a remarkably useful arrow method in my Angular component.
private event_listener_callback = (evt: Event): void => {
// carry out some action
}
Everything was functioning smoothly up until this point.
However, when attempting to spy on the arrow function in a Jasmine unit test using:
spyOn(comp, 'event_listener_callback').and.callThrough();
An error is thrown indicating
TS2345: Argument of type 'string' is not assignable to parameter of type 'never'
.
To resolve this issue, I resorted to utilizing @ts-ignore
, which resolved the error and allowed the unit test to run flawlessly.
Now, I am curious about the appropriate type for the arrow function that can prevent this TypeScript error from occurring.