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

Type infer with the new Loaded and New types #876

Closed
t7yang opened this issue Sep 26, 2020 · 1 comment
Closed

Type infer with the new Loaded and New types #876

t7yang opened this issue Sep 26, 2020 · 1 comment
Assignees

Comments

@t7yang
Copy link

t7yang commented Sep 26, 2020

Describe the bug
I try to upgrade mikro recently and found an interesting error.

mikrov4

Previously in v3.x, content is infer as Content which nice but lack of type safety.

In v4.x the new types Loaded and New introduced in c5f766b try to improve the type safety but somehow content is now infer as IContent which is a pure value object.

I try to digging into the source code and fix it but failed :|

To Reproduce
Steps to reproduce the behavior:

  1. Passing a typed object into the second argument in orm.em.create.
  2. The type of the return value is infer as the type of the object.

Expected behavior
The type of the return value should be an entity.

Versions

Dependency Version
node 14.12.0
typescript 4.0.2
@mikro-orm/core 4.0.7
@mikro-orm/mysql 4.0.7
@B4nan
Copy link
Member

B4nan commented Sep 26, 2020

Interesting. It has nothing to do with the Loaded or New types, the issue is with the T as it was inferred to your IContent. I managed to get around it, the issue was with the EntityData being defined as T | ..., removing that T | fixes it.

@B4nan B4nan closed this as completed in 67f8015 Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants