adamdubicki / typeorm-entity-factory

A TypeORM testing utility for bulk inserting entity objects.
MIT License
10 stars 0 forks source link

getFactory generics problems #12

Open moltar opened 4 years ago

moltar commented 4 years ago

It seems like getFactory requires a generic to be used, yet this is not documented.

Also, there is a second generic argument E, that is not used at all.

Is there a way to fix this so that the type of the factory class inferred from the argument?

//                                            ↓ - this is mandatory, or factory
//                                                becomes "any"
const foo = await factoryContainer.getFactory<UserFactory, any>(UserFactory).make()
//                                                         ↑ - this one is mandatory
//                                                             but isn't needed

https://github.com/adamdubicki/typeorm-entity-factory/blob/a739b3bdec974df33d409064675c553a9e175eb8/src/factory-container.ts#L58

moltar commented 4 years ago

Without generics:

Screen-Shot-2020-04-17-16-16-38
adamdubicki commented 4 years ago

@moltar - Good catch - I will fix these for the next version.