Put in order · JavaScript and TypeScript course · Module 7: Advanced TypeScript

Generic Constraint Hierarchy

Order the constraints from most general to most specific:

Items to put in order

  • <T extends object> - accepts any object
  • <T> - no constraints, accepts any type
  • <T extends Dinosaur> - specific Dinosaur interface
  • <T extends { name: string }> - object with a name field

You can check the correct answer by solving this task in the CodeWorlds game.