Subtype

Noun · Development

Definitions

  1. A type that can be safely used wherever its supertype is expected, satisfying the Liskov Substitution Principle. If `Cat` is a subtype of `Animal`, then any function accepting an `Animal` will also accept a `Cat` without error.

    In plain English: A more specific type that can stand in for a more general one, because it has at least everything the general type promises.

    Example: "string is a subtype of string | number in TypeScript, so you can pass a string anywhere the union is expected."

Related Terms