Skip to content
TS2315

    ↑↓ move · ⏎ open · esc close

    TS2315

    Type is not generic

    Type 'Label' is not generic.

    The compiler’s own words. Not translated — this is the string you pasted into a search box.

    Type arguments were supplied to an alias that declares no type parameters.

    Reproduction

    type Label = string
    
    type Bad = Label<number>

    The build asserts this emits exactly this code.

    Why the compiler says this

    Angle brackets instantiate a generic declaration. A fixed alias such as `Label = string` has nothing to substitute, so `Label<number>` is no more meaningful than passing an argument to a constant.

    Fixes

    1. 01
      type Label = string
      
      type NameLabel = Label

      Remove the type argument when the alias is intentionally fixed.

    2. 02
      type Label<T> = { value: T }
      
      type NumberLabel = Label<number>

      Declare a parameter when the alias is meant to vary with its input.

    Takeaway

    The declaration decides whether a type is generic; use-site angle brackets cannot make it so.

    Where to go next

    Errors