Question · JavaScript and TypeScript course · Module 7: Advanced TypeScript

Practical Use of Omit

Given interface Dinosaur { name: string; age: number; dna: string }, what will Omit<Dinosaur, 'dna'> return?

Answer options

  • A type with name: string and age: number fields (without dna)
  • A type containing only the dna: string field
  • A type with all fields as optional
  • Compilation error - cannot remove a field from an interface

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