Skip to content

TS4144: Indexed type must have a type annotation

Error message

                The type of a computed property name must be unique.
              

Quick summary

There's an issue with the computed property or mapped type key. The key type needs to be properly constrained.

Why this happens

  • Mapped type key is not properly constrained

  • Computed property name has an invalid type

Minimal example

✗ Broken code
type Bad<T> = { [K in T]: string }; // TS4144: T not constrained
✓ Fixed code
type Good<T extends string> = { [K in T]: string }; // ✅

Constrain T to string so it can be used as a mapped type key.

How to diagnose

  • Check the mapped type syntax

  • Verify the key type is string, number, or symbol

How to fix

  • Add proper type constraints to the key

  • Fix the mapped type syntax

← Back to language