Closed Copystrike closed 8 months ago
Cool, thanks!
CI is running/has finished running commands for commit c4d712d634a4ba5d3ea0760ba162d40e33fbec78. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
📂 See all runs for this CI Pipeline Execution
Sent with 💌 from NxCloud.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 86.27%. Comparing base (
6bb3bdd
) to head (c4d712d
). Report is 1 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Ahh, some of the test failed, my bad. Thought this was going to be an easy fix, will see if I can get this fixed asap.
I might need some assistance with this problem. Basically, the issue is that in ClassTransformerAssembler
, the types are set explicitly. This causes trouble when trying to use async functions because TypeScript can't figure out if users want a promise or the actual type.
So, if people don't use async, they have to specify the type they want like this:
convertToDTO(entity: TodoItemEntity): TodoItemDTO {
const dto = super.convertToDTO(entity) as TodoItemDTO
dto.age = Date.now() - entity.createdAt.getMilliseconds()
return dto
}
This could lead to breaking changes in the type checking process, because it forces changes in how things are done.
Another idea is to create a new class called AsyncClassTransformerAssembler
. But I'm not a fan of this because it means more work to maintain and limits using both async and non-async functions in a single class.
Let's just update it and mark it a breaking change. Don't forget to add BREAKING CHANGE:
into the commit body like here
Let's just update it and mark it a breaking change. Don't forget to add
BREAKING CHANGE:
into the commit body like here
Done, breaking change notice is included.
Normally this time it should be able to pass the tests!
In the AbstractAssembler, there are several methods that provide the option to be async.
https://github.com/TriPSs/nestjs-query/blob/b5c761bd42ceccfd8d68e34722706b463b31d73c/packages/core/src/assemblers/abstract.assembler.ts#L37-L39
https://github.com/TriPSs/nestjs-query/blob/b5c761bd42ceccfd8d68e34722706b463b31d73c/packages/core/src/assemblers/abstract.assembler.ts#L47-L49
However, in the ClassTransformerAssembler class, when extending these abstract methods, we explicitly set return types to one of the two return type options:
https://github.com/TriPSs/nestjs-query/blob/b5c761bd42ceccfd8d68e34722706b463b31d73c/packages/core/src/assemblers/class-transformer.assembler.ts#L20-L26
https://github.com/TriPSs/nestjs-query/blob/b5c761bd42ceccfd8d68e34722706b463b31d73c/packages/core/src/assemblers/class-transformer.assembler.ts#L40-L46
Which cause this in my project:
Which prohibited the use of the async option.
When I change the types:
Everything works as expected:
Which is what I hope this PR achieved!