Is it possible to have a field in a class that is not accessible from the outside, but still accessible by other classes that are defined within the same file / package / folder where the class is declared?
I wish to use the field internally in my library, but it is not supposed to be accessible for library users.
Simplified example from my code:
class RunningAnimation {
package private onDraw: (state: Object) => void;
}
class AnimationSystem {
private runningAnimations: Set<RunningAnimation>;
public draw(): void {
for (const animation of this.runningAnimations) {
// this should be accessible
// only from within the lib
// but not to library users
animation.onDraw({ foo: "bar" });
}
}
}