-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix(base-entity): set create return type to T[] #5400
Conversation
Thanks! |
FYI this broke existing code in a way described in this issue: #1583 (comment) tl;dr; this code: const foo = Foo.create({ ...req.body }) // req.body is `any`
console.log(foo.bar) suddenly breaks, because before the update This might be TS fault instead TypeORM's fault, I'm not sure. But since it's breaking working code, it definitely requires a second look. |
Same for me. This broke the existing code. |
I thought it was TypeScript(microsoft/TypeScript#37471), but turned out to be this. |
Has there been any update on this / more background on why this was changed. It also broke existing code on our project. |
@pleerock look here. this pr introduce a breaking change |
Type signature seems to be right. It expects an array and we get array back. I don't see how it can be wrong right now, can somebody point me what can be wrong ? |
@pleerock The code looks good, but its usage is crooked. The problem is that when using object spread operator in the |
okay, but this PR definitely fixes issue. Not sure how can I help with particular this use case when you use |
What's the problem this PR addresses?
The version of
BaseEntity.create
that takes an array ofentityLike
objects returns an array of entities but the return type incorrectly specifies that it's a single entity.How did you fix it?
Changed the return type from
T
toT[]