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

Deprecate @Type and provide better @Nested #1680

Closed
wants to merge 21 commits into from
Closed

Deprecate @Type and provide better @Nested #1680

wants to merge 21 commits into from

Conversation

temeddix
Copy link

@temeddix temeddix commented Feb 12, 2024

Description

The @Type decorator had 2 problems:

  • 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

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

Fixes

fixes #[issue number], fixes #[issue number]

@cunarist cunarist closed this by deleting the head repository Feb 12, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants