You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The New type that gets returned from .create() methods does some funky things. It seems to strip nullability from properties.
Stack trace
No stack trace, as it's a type issue.
To Reproduce
Reproducing this is very simple using just a class and the New type.
classMyEntity{
@Property({nullable: true})nullableProperty: null|string;}// Type `null` is not assignable to `string`constmyNewEntityInstance: New<MyEntity>={nullableProperty: null,};
I know we would never instantiate a New<MyEntity> like above, but whether we do it via a create call or manually makes no difference for the type information.
Expected behavior
It should not modify the entity's type information. The actual type result from a .create() call is now potentially incorrect.
In the above example null is an allowed value for the MyEntity class.
Versions
Dependency
Version
node
16.13.1
typescript
4.5.5
mikro-orm
5.0.0
your-driver
postgresql
The text was updated successfully, but these errors were encountered:
Describe the bug
The
New
type that gets returned from.create()
methods does some funky things. It seems to strip nullability from properties.Stack trace
No stack trace, as it's a type issue.
To Reproduce
Reproducing this is very simple using just a class and the
New
type.I know we would never instantiate a
New<MyEntity>
like above, but whether we do it via a create call or manually makes no difference for the type information.Expected behavior
It should not modify the entity's type information. The actual type result from a
.create()
call is now potentially incorrect.In the above example
null
is an allowed value for theMyEntity
class.Versions
The text was updated successfully, but these errors were encountered: