feat(entity-generator): added ability to output type option in decorator #4935
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried to run the tests with
@swc/jest
(yes, I did saw #3200, but I thought I take a fresh crack at it, since that branch is over a year old...), and an interesting error that popped up was the inability to discover the entity type.Featuring the type is one way to avoid this... another way is to not use SWC or to use
EntitySchema
(which is the solution I intend to use for my projects personally...).So... for users who intend to use SWC, and would like to use decorators, I think it would be very beneficial to be able to generate the "type" option. For everyone else, it would just provide a minor boost in startup performance of a project using generated entities with decorators.
Being a very limited option in scope, implementation was easy. Honestly, whether this should be an option and whether it should default to
true
orfalse
is debatable... but I thought I just set it as an option defaulting tofalse
for the sake of BC to avoid this debate... I mean, I think it's OK for it to not be an option and just always default totrue
... but that requires modification in existing tests if nothing else.Side note: Because of the way SWC works, I fear the only way to possibly switch to it would be to support BOTH
@swc/jest
andts-jest
in all tests but those that require reflection... and in CI, run those that require reflection separately withts-jest
while most others would run in@swc/jest
.