What does `type NonNullable = T extends null | undefined ? never : T` accomplish?

TypeScript Professional Hard

TypeScript Professional — Hard

What does `type NonNullable = T extends null | undefined ? never : T` accomplish?

Key points

  • NonNullable eliminates null and undefined from T
  • Ensures T is not optional
  • Prevents T from being assigned null or undefined values

Ready to go further?

Related questions