Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forFeature method not accepting EntitySchema as valid type for entities argument #79

Closed
perebusquets opened this issue Jun 21, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@perebusquets
Copy link

perebusquets commented Jun 21, 2022

Describe the bug
First of all, awesome project, keep the great work! :)

I´m trying to use to use MikroORM in NestJS setup as a monorepo (so no glob file patterns for me), and trying to use the autoLoadEntities option to be able declare the entities in each module via forFeature.
The problem is that I would like to use EntitySchema declaration instead of using decorators, and the type in the forFeature method doesn't allow them.
I've checked that, if I ignore the typescript error, everything works fine, so my guess is that it's just an oversight of not also declaring EntitySchema as a valid type there.

Stack trace

Type 'EntitySchema<Account, undefined>' is not assignable to type 'EntityName<AnyEntity<any>>'.

To Reproduce
Steps to reproduce the behavior:

  1. Instantiate MikroOrmModule with autoLoadEntities option enabled.
  2. Declare in the forFeature method the EntitySchema you want to use.
  3. Typescript explodes
  4. Ignore TS error
  5. Everything works as expected

Expected behavior
forFeature method to allow for EntitySchema type.

Versions

Dependency Version
node 16.15.1
typescript 4.7.4
mikro-orm 5.2.0
mongodb-driver 5.2.0
@perebusquets perebusquets added the bug Something isn't working label Jun 21, 2022
@B4nan
Copy link
Member

B4nan commented Aug 14, 2022

That's weird. The EntityName type comes from the ORM and explicitly has the EntitySchema in union:

https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/typings.ts#L148

Aparently its caused by the generic type value.

@B4nan B4nan closed this as completed in c0012c9 Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants