cf.completefrontend

Predict the typesHard

Which of these event handler assignments does TypeScript reject, and why does the method version compile?

strict is on, which includes strictFunctionTypes. Name every error TypeScript reports, and the type the ^? line points at.

What does TypeScript report here?
type Listener = (event: Event) => void;type WithMethod = { handle(event: Event): void };type WithProperty = { handle: (event: Event) => void }; const onPointer = (event: MouseEvent) => console.log(event.clientX);const onAny = (event: Event) => console.log(event.type); const a: Listener = onAny;const b: Listener = onPointer;const c: (event: MouseEvent) => void = onAny;const d: WithMethod = { handle: onPointer };const e: WithProperty = { handle: onPointer }; const handlers = [onPointer, onAny];//    ^?

Work it out first: the compiler shows every error and type.

The answer

Work out every error TypeScript reports and every type it shows, line by line. Then check.

Checking your sign-in…