TS7008

error TS7008: Member ‘name‘ implicitly has an ‘any’ type.

Broken Code ❌

1
2
3
abstract class Person {
accessor name;
}

Fixed Code ✔️

To fix the problem, you can initialize the class member so that TypeScript can infer the type:

1
2
3
abstract class Person {
accessor name = 'unknown';
}

Alternatively, you can annotate the type:

1
2
3
abstract class Person {
accessor name: string;
}