Minimal code-snippet showcasing the problem
export class CreateClassDto {
@IsOptional()
@IsNumber()
id: number;
@ApiProperty({ example: 'CLASS-1' })
@IsString()
@IsNotEmpty()
class_name: string;
@ApiProperty({ example: '1' })
@IsNotEmpty()
@IsNumberString()
floor: string;
@ApiProperty({ example: 'This classe include yoga hit and aerobics' })
@IsString()
@IsOptional()
description: string;
@ApiProperty({ example: 1, description: 'staff id ' })
@IsNumber()
@IsOptional()
creator_id: number;
}
===========This class I extends from CreateClassDto and it got error
import { PartialType } from '@nestjs/mapped-types';
import { CreateClassDto } from './create-class.dto';
export class UpdateClassDto extends PartialType(CreateClassDto) {}
==========Error Message ====
[Nest] 15036 - 01/22/2021, 3:15:49 PM [MappedTypes] Transformer ("class-transformer") metadata cannot be inherited for "CreateClassDto" class.
[Nest] 15036 - 01/22/2021, 3:15:49 PM [MappedTypes] Object:
{
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/mapped-types/dist/type-helpers.utils.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/mapped-types/dist/intersection-type.helper.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/mapped-types/dist/index.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/mapped-types/index.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/swagger/dist/type-helpers/intersection-type.helper.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/swagger/dist/type-helpers/index.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/swagger/dist/index.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/node_modules/@nestjs/swagger/index.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/dist/config/swagger/config-swagger.js",
"/Users/rom/Documents/workspace/gym-project/gym-api/dist/main.js"
]
}
"dependencies": {
"@nestjs/mapped-types": "^0.1.1",
"class-transformer": "0.3.1",
},
In case everyone meets this problem just downgrade package class-transformer to 0.3.1 and @nestjs/mapped-types to 0.1.1
Reopening as downgrading is not a solution for forever.
Looking at your code the error comes from the Nest package not us. Maybe open an issue there and link it back? I believe we will need some co-opeartion to solve this.
This can be resolved by upgrading @nestjs/mapped-types to v0.2.0 or newer. So it seems closing this is appropriate @NoNameProvided.
I encountered a similar error, both suggestions provided above worked for me:
@nestjs/mapped-types to 0.3.0 (latest), orclass-transformer and mapped-types to 0.3.1 and 0.1.0, respectively. Note: I had to update @nestjs/graphql from 7.9.4 to 7.9.8 (latest) in order to update its mapped-types dependency to 0.3.0 (latest).
Thanks, closing as solved.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
This can be resolved by upgrading
@nestjs/mapped-typesto v0.2.0 or newer. So it seems closing this is appropriate @NoNameProvided.