Course contentsShow
← TypeScript
Lesson 1493 of 1,79634. The Limits of TypeScriptFree lesson

Concrete Types vs Abstract Type Constructors

Recognizing when to use specific Array<T> or Promise<T> code instead of trying to abstract over them.

Concrete Types vs Abstract Type Constructors

You'll learn when to use specific types like Array<T> or Promise<T> directly instead of attempting to abstract over them with higher-kinded type patterns.


The Core Distinction

In TypeScript, a concrete type is a fully instantiated type you can actually use: Array<number>, Promise<string>, Set<User>. An abstract type constructor would be the concept of Array, Promise, or Set without the type argument—the "container shape" itself.

The key insight: TypeScript doesn't let you abstract over type constructors. You can't write a function that works generically over "any container F" where F could be Array, Promise, or Set interchangeably.

Why This Matters

When building utilities, you might be tempted to write something that works with "any wrapper type." But TypeScript forces you to choose:

  • Work with concrete instantiated types: function mapArray<T, U>(arr: Array<T>, fn: (x: T) => U): Array<U>
  • Accept the specific type constructor: You must write separate functions for Array, Promise, Set, etc.

You cannot write a single function signature that says "works for any F<T>."

Practical Guidance

✅ Embrace concrete types:

  • Write Array<T> helpers specifically for arrays
  • Write Promise<T> helpers specifically for promises
  • Don't try to abstract them into a single generic "container" type

❌ Avoid over-abstraction:

  • Don't attempt complex workarounds to simulate higher-kinded types unless you truly need framework-level abstractions
  • The cognitive overhead usually isn't worth it for application code

Think of it like this: you wouldn't try to write a single JavaScript function that works identically on arrays, promises, and sets—they have fundamentally different behaviors. TypeScript's type system reflects this reality.

Key Takeaway: Work with concrete instantiated types like Array<T> and Promise<T> directly rather than trying to abstract over the type constructors themselves—TypeScript's type system doesn't support true higher-kinded abstraction, and forcing it creates more complexity than value.