TS2680
A 'this' parameter must be the first parameter.
Broken Code ❌
type Person = {
name: string;
};
export function sayHello(text: string = 'Hello', this: Person): void {
console.log(`${text} ${this.name}`);
}Fixed Code ✔️
TypeScript requires that a this parameter always comes first in the list of parameters:
type Person = {
name: string;
};
export function sayHello(this: Person, text: string = 'Hello'): void {
console.log(`${text} ${this.name}`);
}