cf.completefrontend

Predict the typesMedium

What's the difference between void and undefined as a return type? What does TypeScript report here, and what does it log?

Name the type the ^? line points at, every error TypeScript reports, and what the code logs when you run it with its types removed.

What does TypeScript report here?
type Callback = () => void; const items: number[] = [];const save: Callback = () => items.push(42);const result = save();//    ^? function log(message: string): void {  console.log(message);  return message.length;} function clear(): undefined {  items.length = 0;} const total: number = save();console.log(result, items.length);

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…