• Error
  • Reported by the type checker

TS1249

A decorator can only decorate a method implementation, not an overload.

A decorator is on an overload signature instead of the method implementation. Move it to the implementation.

What it means

Overload signatures have no runtime code, so they can't be decorated. Only the implementation, the declaration with a body, can carry decorators.

Example

index.ts
function log(target: unknown, context: ClassMethodDecoratorContext) {}

export class Api {
  @log
  get(id: number): string;
  get(id: string): string;
  get(id: number | string): string {
    return String(id);
  }
}
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(4,3): error TS1249: A decorator can only decorate a method implementation, not an overload.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Put the decorator on the implementation signature (the one with the body).