TS18016

error TS18016: Private identifiers are not allowed outside class bodies.

Broken Code ❌

1
2
3
interface Person {
#age: number;
}

Fixed Code ✔️

Private properties can only be used in classes but not in interfaces. We therefore need to convert the interface into a class in order to be able to compile the code:

1
2
3
class Person {
#age: number;
}