- Error
- Reported by the type checker
TS1433
Neither decorators nor modifiers may be applied to 'this' parameters.
A decorator or a modifier such as `public` is applied to a `this` parameter. Remove it.
What it means
A this parameter only declares the type of this inside a function. It isn't a real parameter, so it can't have decorators or modifiers like public or readonly.
Example
declare function track(...args: unknown[]): void;
export class Counter {
count = 0;
increment(@track this: Counter) {
this.count++;
}
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(5,13): error TS1433: Neither decorators nor modifiers may be applied to 'this' parameters.
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
- Remove the modifier or decorator from
this.