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(decorators): avoid setting type property on globals like String and Date #1223

Closed
wants to merge 2 commits into from

Conversation

vkarpov15
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • [X ] 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?

@Prop(String) results in Nest setting String.type = String, which has caused some issues in Mongoose: Automattic/mongoose#11199, Automattic/mongoose#10807

Issue Number: N/A

What is the new behavior?

@Prop(String) treated as @Prop({ type: String })

Does this PR introduce a breaking change?

  • Yes
  • [X ] No

Other information

@micalevisk
Copy link
Member

looks like you'll need to update this test as well:

it('should generate a valid schema definition', () => {

@kirtan403
Copy link

When this be merged? We have upgraded our project from nest v7 to v8 and we are stuck because of this issue. We have a Location schema with type and coordinates keys and it throws validation failed: location.type: Cannot create property 'coordinates' on string 'Point'

@Schema()
export class Location {
  @Prop({ required: true, enum: ['Point'] })
  type: string

  @Prop({ type: [Number], required: true })
  coordinates: number[]
}

@kamilmysliwiec
Copy link
Member

Tests are currently failing for this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants