Created
September 14, 2022 14:09
-
-
Save fr1sk/47314ccf1283eeacbb678409f7ced3d0 to your computer and use it in GitHub Desktop.
pick-type-problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestDto { | |
@ApiProperty({ type: String, required: true }) | |
@IsString() | |
@IsDefined() | |
id: string; | |
@ApiProperty({ type: String, required: true }) | |
@IsString() | |
@IsDefined() | |
testId: string; | |
@ApiProperty({ type: String, required: true }) | |
@IsNumber() | |
value: number; | |
} | |
const SMALLER_TEST_DTO_REQUIRED_FIELDS: Array<keyof TestDto> = ["id", "testId"]; | |
class SmallerTestExpectedDto extends PickType(TestDto, ["id", "testId"]) {} | |
class SmallerTestUnexpectedDto extends PickType(TestDto, SMALLER_TEST_DTO_REQUIRED_FIELDS) {} | |
const smallerTestExpected: SmallerTestExpectedDto = { | |
id: "id", | |
testId: "test", | |
}; | |
const smallerTestUnexpected: SmallerTestUnexpectedDto = { | |
id: "id", | |
testId: "test", | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment