QuizNot attempted
What T extends {} allows
1–4 to choose, Enter to submit
Show answer & explanation
Correct answers:
0and''{ id: 1 }
{}means 'any value that isn'tnullorundefined', so primitives like0and''satisfy it just like objects do- it is the standard way to say 'non-nullish', and
NonNullable<T>is defined asT & {}. - Not null: under
strictNullChecksnullis excluded. - Not undefined: likewise excluded.
- Use
objectif you really mean non-primitive, orRecord<string, unknown>for a plain object.