This compiles with no errors. What does it log, and where does TypeScript's type safety break down?
Name the type the ^? line points at, and what the code logs when you run it with its types removed.
type User = { name: string; age: number }; const users: User[] = [];const first = users[0];// ^? const admins: { name: string; role: "admin" }[] = [];const people: { name: string }[] = admins;people.push({ name: "Grace" }); const raw: unknown = JSON.parse('{ "name": "Ada" }');const ada = raw as User; console.log(first);console.log(admins[0].role);console.log(ada.age.toFixed(0));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…