When attempting to modify the access level on an interface in Typescript, I encountered an error stating 'cannot appear in type member.' After removing the access limiter on the interface and implementing it, I tried changing the access limiter on the class.
interface car {
private speed: number;
}
Unfortunately, this did not work as expected.
interface car {
speed: number;
}
This change did work successfully.
class MyCar implements car {
private speed: number;
}
However, this did not work as intended.
class MyCar implements car {
public speed: number;
}
This modification worked properly.
Is it possible for an interface to have an access limiter? Or can an implemented interface restrict access with private or protected levels on a class?