Skip to content

interface-contract-members-private

Require methods outside an implemented interface contract to use ECMAScript private names.

Why

An implementing class should expose exactly its declared interface while keeping implementation helpers runtime-private.

Fix

Add the method to the interface when it is public API, or make it #private and remove external or inherited access.

Examples

Before — flagged Do not grow an undeclared public surface
src/store.ts
interface Store {
load(): void;
}
class DiskStore implements Store {
load() {
this.read();
}
read() {}
}
After — preferred Keep helpers behind the runtime boundary
src/store.ts
interface Store {
load(): void;
}
class DiskStore implements Store {
load() {
this.#read();
}
#read() {}
}