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

IntersectionType breaks returning value of methods #1321

Open
2 of 4 tasks
maioradv opened this issue Feb 16, 2024 · 4 comments
Open
2 of 4 tasks

IntersectionType breaks returning value of methods #1321

maioradv opened this issue Feb 16, 2024 · 4 comments

Comments

@maioradv
Copy link

maioradv commented Feb 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I'm trying to interect two classes to obtain a dto like that:

export class QueryPageDto extends IntersectionType(PartialType(OmitType(CreatePageDto,['metafields','translations'])),PaginationDTO) {}
export default class PaginationDTO {
  @ApiProperty({
    minimum: 1,
    default: 1,
  })
  @IsNumber()
  @IsOptional()
  @IsInt()
  @Min(1)
  @Type(() => Number)
  readonly page?:number = 1;

  @ApiProperty({
    minimum: 1,
    maximum: 250,
    default: 50,
  })
  @IsNumber()
  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(250)
  @Type(() => Number)
  readonly limit?:number = 50;

  get skip(): number {
    return (this.page - 1) * this.limit;
  }

  get take(): number {
    return this.limit;
  }
}

but when i type queryPageDto.skip (or take) also if is suggested they always returns undefined
i tried that whitout IntersectionType and obviously works.

Minimum reproduction code

https://github.com

Steps to reproduce

No response

Expected behavior

I'm expecting returning values

Package version

2.0.5

Node.js version

20.11.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

"@nestjs/mapped-types": "*",
"@nestjs/swagger": "^7.2.0",

@maioradv maioradv changed the title IntersectionType break methods IntersectionType breaks value returning of methods Feb 16, 2024
@maioradv maioradv changed the title IntersectionType breaks value returning of methods IntersectionType breaks returning value of methods Feb 16, 2024
@jmcdo29
Copy link
Member

jmcdo29 commented Feb 16, 2024

Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).

why reproductions are required

@maioradv
Copy link
Author

maioradv commented Feb 19, 2024

Try /test

https://codesandbox.io/p/devbox/brave-christian-c22g5q?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clssokgns0007356hb14awecx%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clssokgnr0002356hexe3ch7w%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clssokgnr0004356hzvmciyvx%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clssokgns0006356h6j4h35i9%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clssokgnr0002356hexe3ch7w%2522%253A%257B%2522id%2522%253A%2522clssokgnr0002356hexe3ch7w%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clssokgnq0001356hye8i8apd%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clssokgnq0001356hye8i8apd%2522%257D%252C%2522clssokgns0006356h6j4h35i9%2522%253A%257B%2522id%2522%253A%2522clssokgns0006356h6j4h35i9%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522start%253Adev%2522%252C%2522port%2522%253A3000%252C%2522id%2522%253A%2522clssp04fw01aw356hnm8a1wag%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clssp04fw01aw356hnm8a1wag%2522%257D%252C%2522clssokgnr0004356hzvmciyvx%2522%253A%257B%2522id%2522%253A%2522clssokgnr0004356hzvmciyvx%2522%252C%2522activeTabId%2522%253A%2522clssozwfa0184356h0yysnrc7%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clssorj3300vu356hlya0u1s5%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clssoqc0y006xdjq4cu2zgsc2%2522%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522start%253Adev%2522%252C%2522id%2522%253A%2522clssozwfa0184356h0yysnrc7%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

@jmcdo29
Copy link
Member

jmcdo29 commented Feb 19, 2024

Looks like your issue is that the IntersectionType removes the getters that you have set, which I believe is the expected behavior, right @kamilmysliwiec?

@kamilmysliwiec
Copy link
Member

That's correct @jmcdo29

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

3 participants