Skip to content

QuizNot attempted

What T extends {} allows

A generic List<T extends {}> component constrains its items. Which values satisfy {}?

Select all that apply.

1–4 to choose, Enter to submit
Show answer & explanation

Correct answers:

  • 0 and ''
  • { id: 1 }
  • {} means 'any value that isn't null or undefined', so primitives like 0 and '' satisfy it just like objects do
  • it is the standard way to say 'non-nullish', and NonNullable<T> is defined as T & {}.
  • Not null: under strictNullChecks null is excluded.
  • Not undefined: likewise excluded.
  • Use object if you really mean non-primitive, or Record<string, unknown> for a plain object.