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

connect DTO - Subsequent property declarations must have the same type. #35

Open
ReptoxX opened this issue Jan 10, 2024 · 2 comments
Open

Comments

@ReptoxX
Copy link

ReptoxX commented Jan 10, 2024

On every connect DTO is an typescript error, that the field is defined twice with different types.

import { ApiExtraModels, ApiProperty } from '@nestjs/swagger';

class UserIdUniqueInputDto {
	@ApiProperty({
		default: 'cuid',
	})
	id!: string;
}

@ApiExtraModels(UserIdUniqueInputDto)
export class ConnectUserDto {
	@ApiProperty({
		required: false,
		nullable: true,
	})
	id?: string;
	@ApiProperty({
		required: false,
		nullable: true,
	})
	mail?: string;
	@ApiProperty({
		type: UserIdUniqueInputDto,
		required: false,
		nullable: true,
	})
	id?: UserIdUniqueInputDto;
}

Parameters used:

generator nestrestapi {
  provider                        = "prisma-generator-nestjs-dto"
  output                          = "../models/@generated/rest"
  definiteAssignmentAssertion     = true
  prettier                        = true
  reExport                        = true
  outputToNestJsResourceStructure = true
  exportRelationModifierClasses   = false
}
@ReptoxX ReptoxX changed the title connect DTO's comes with same value twice. connect DTO - Subsequent property declarations must have the same type. Jan 10, 2024
@ReptoxX
Copy link
Author

ReptoxX commented Jan 10, 2024

The problem is i use @@id([id]) to define the id of the table.
Example

model User {
  id             String     @default(cuid())
  mail           String     @unique

  @@id([id])
  @@map("users")
}

When using

model User {
  id             String     @default(cuid()) @id
  mail           String     @unique

  @@map("users")
}

the error does not occur.

@Brakebein
Copy link
Owner

I think it's a bug with having only one value within the array of @@id(). It is possible that unique constraint with only one value, e.g. @@unique([mail]), behaves similar. I need to check it.

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

No branches or pull requests

2 participants