Skip to content
webtype.orgInstanceType

    ↑↓ move · ⏎ open · esc close

    Functions

    InstanceType

    What a constructor produces when you call it with `new`.

    What it is

    The class version of `ReturnType`, and the reason it exists separately is that a class name means two things: the constructor value and the instance type. `typeof Foo` is the constructor; `Foo` is already the instance. `InstanceType` matters when you only have the constructor — passed as an argument, stored in a registry, produced by a factory.

    Examples

    • InstanceType<typeof Session>
      Session
    • ConstructorParameters<typeof Session>
      []
    • InstanceType<typeof Session>['id']
      string

      Once you have the instance type, everything else — `keyof`, indexed access, mapped types — applies as normal.

    Each resolved type above was printed by TypeScript 5.9.3, not written by hand.

    What it does not do

    • It does not accept the class name directly. `InstanceType<Session>` is an error, because `Session` is already the instance — you want `typeof Session`.
    • It does not include static members. Those live on the constructor, which is the thing you passed in, not the thing you got out.

    Takeaway

    A class name is two types wearing one word. `typeof C` is the constructor, `C` is the instance, and almost every confusing class-generic error is those two swapped.