Hi!
I don't understand why a2's value does not respect type a. TS says:
Type '(n: number) => void' is not assignable to type 'a'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
Which I do not understand. I would expect it to accept a function that has 1 parameter.
type a = {
(): void;
(n: number): void;
}
type b = (() => void) | ((n: number) => void)
const a1: a = () => {}
const a2: a = (n: number) => {}
const b1: b = () => {}
const b2: b = (n: number) => {}
Can someone explain to me what's wrong?
Le playground vous permet d'écrire du TypeScript ou du JavaScript en ligne de manière sûre et partageable.