Its name makes itself look like a general type decorator for any variables. However, it's actually only for 'nested class properties'
Its syntax was unnecessarily dirty: @Type(() => MyClass))
This PR introduces a new @Nested decorator, deprecating @Type, with better JSDoc comments and usage syntax.
Before:
class Photo {
id!: number;
filename!: string;
depth!: number;
}
class Pages {
table!: number;
contents!: number;
}
class Album {
id!: number;
name!: string;
@Type(() => Photo)
photos!: Array<Photo>;
@Type(() => Pages)
pages!: Pages;
}
After:
class Photo {
id!: number;
filename!: string;
depth!: number;
}
class Pages {
table!: number;
contents!: number;
}
class Album {
id!: number;
name!: string;
@Nested(Photo)
photos!: Array<Photo>;
@Nested(Pages)
pages!: Pages;
}
Documentations are all properly updated. Users using VSCode will receive deprecation warning because @Type is now marked with @deprecated, so that they can gradually transition later on.
Checklist
[x] the pull request title describes what this PR does (not a vague title like Update index.md)
[x] the pull request targets the default branch of the repository (develop)
[x] the code follows the established code style of the repository
npm run prettier:check passes
npm run lint:check passes
[x] tests are added for the changes I made (if any source code was modified)
[x] documentation added or updated
[x] I have run the project locally and verified that there are no errors
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Description
The
@Type
decorator had 2 problems:@Type(() => MyClass))
This PR introduces a new
@Nested
decorator, deprecating@Type
, with better JSDoc comments and usage syntax.Before:
After:
Documentations are all properly updated. Users using VSCode will receive deprecation warning because
@Type
is now marked with@deprecated
, so that they can gradually transition later on.Checklist
Update index.md
)develop
)npm run prettier:check
passesnpm run lint:check
passesFixes
fixes #[issue number], fixes #[issue number]