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

fix(plugin): Fix nullable enum not having a proper enum type #2553

Merged

Conversation

Spissable
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently when having a nullable enum SomeEnum | null, the generated output from the plugin is missing the enum attribute. It looks like this in the unit test:

...
nullableEnumValue: { required: true, nullable: true }
...

This would further down the line crash the application start with this error:

throw new Error(
`A circular dependency has been detected (property key: "${key}"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").`
);

My usual workaround was to manually annotate these cases, however, I implemented a fix with this PR for the plugin.

What is the new behavior?

With this fix, the generated output look as expected:

...
nullableEnumValue: { required: true, nullable: true, enum: OneValueEnum }
...

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@Spissable Spissable force-pushed the bug/nullable-enum-without-enum-type branch from b304148 to c1362f1 Compare August 5, 2023 09:14
@Spissable Spissable force-pushed the bug/nullable-enum-without-enum-type branch from c1362f1 to 6dad8f6 Compare August 5, 2023 09:15
@kamilmysliwiec kamilmysliwiec merged commit b73349e into nestjs:master Aug 7, 2023
1 check passed
@kamilmysliwiec
Copy link
Member

LGTM

@Spissable Spissable deleted the bug/nullable-enum-without-enum-type branch August 7, 2023 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants