-
Notifications
You must be signed in to change notification settings - Fork 20
Conversation
The factory reference type can't extend the Datastore interface directly. We want the class instance to implement the interface and not the class (Object) reference.
Why would the factory extend the datastore? It should create datastores, not be a datastore. |
exactly thats the problem this PR fixes |
I can see that in the removal of |
that way TS can infere if a the output of Without it i can assign a partially implemented |
But in the factory pattern a const factory = new DatastoreFactoryImpl()
const datastore = factory.create() A datastore impl might implement both class MyDatastore implements Datastore, DatastoreFactory {
// ...Datastore methods
create () {
return new MyDatastore()
}
} |
humm this isn't actually the factory pattern, its just an extra type for the class object because we can't write class types in |
If it's not the factory pattern, why is it called |
Suggestions ? |
Will this not work? ipfs/js-ipfs-repo#275 (comment) Then you don't need |
sure we can do that, and i also confirmed that prototype is not needed. i would still like to have a type here, i changed the name to |
It's a better name, less confusing, but do we really need it or can we delete it entirely? |
your suggestion works and is enough, i just think having a type properly defined here can't hurt. |
The YAGNI principle says we should add that when we need it.. |
gone |
The factory reference type can't extend the Datastore interface directly.
We want the class instance to implement the interface and not the class (Object) reference.