0 of 6 problems solved0%
3 of 6

Excess Property Check: Only Known Props

When you pass an object literal to a function, TypeScript performs an excess property check: extra keys that aren’t in the expected shape are flagged. This helps catch typos like 'naem' instead of 'name'.

Model a basic user shape and ensure only known properties are allowed.

Your Task

  • Complete the function requireBasicUser(u: { id: number; name: string }): number.
  • Return u.id.
  • In type tests we’ll try passing an object literal with an extra property and expect a type error.

Examples

  • requireBasicUser({ id: 1, name: 'A' }) → 1