cf.completefrontend

Predict the typesMedium

What does TypeScript infer for these array literals?

Name the type each ^? line points at, and every error TypeScript reports.

What does TypeScript report here?
const mixed = [1, "two"];//    ^?const maybe = [1, null];//    ^?const people = [{ name: "Ada" }, { name: "Grace", age: 36 }];//    ^?const age = people[0].age;//    ^?mixed.push(true);

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…