1

Please check out this code

class A<T = any> {
  @ApiProperty({ example: 'Success' })
  message: string;
  @ApiProperty({})
  data: T;
}

export const SwaggerEssentials = <T>(okRes?: apiOkResponse) => {
  return applyDecorators(
    ApiResponse({ type: A<T>, status: 200 }), // The error is popping up here
  );
};

The error is popping up when I try to use T with A generic value.

  • This question seems very similar to my question. https://stackoverflow.com/questions/68823518/how-to-change-type-of-property-via-docorators In there you can find: "can't do this because the decorator runs at runtime but the type analysis happens at compile time. But" – Kordrad Mar 14 '22 at 06:13
  • 2
    Hi, @Kordrad thanks but this is not helpful. – Ali Hussnain - alichampion Mar 14 '22 at 06:16

0 Answers0