TS1278
TypeScriptERRORNotableSyntaxHIGH confidence
The runtime will invoke the decorator with X arguments, but the decorator exp...
Production Risk
Build will fail; resolve before shipping.
What this means
A syntax error (TS1278): The runtime will invoke the decorator with X arguments, but the decorator expects X.. This diagnostic is emitted by the TypeScript compiler when the runtime will invoke the decorator with X arguments, but the decorator expects X..
Why it happens
- 1A decorator is applied incorrectly or to an unsupported target
- 2The 'experimentalDecorators' flag may need to be enabled
How to reproduce
TypeScript compiler reports TS1278 during type checking.
trigger — this will error
trigger — this will error
// Triggers TS1278 // The runtime will invoke the decorator with X arguments, but the decorator expects X.
expected output
error TS1278: The runtime will invoke the decorator with X arguments, but the decorator expects X.
Fix
Enable experimentalDecorators
WHEN Using legacy decorator syntax
Enable experimentalDecorators
// tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}Why this works
Decorators require the 'experimentalDecorators' flag; TypeScript 5.0+ also supports the TC39 Stage 3 decorator proposal without the flag.
Sources
Official documentation ↗
TypeScript Compiler Diagnostics
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev