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

Better typescript types #252

Open
3 tasks done
D-Sketon opened this issue May 16, 2024 · 3 comments
Open
3 tasks done

Better typescript types #252

D-Sketon opened this issue May 16, 2024 · 3 comments

Comments

@D-Sketon
Copy link
Member

Check List

  • I have already read README.
  • I have already searched existing issues.
  • I have already searched existing pull requrests.

Feature Request

There are still some problems with the current type labeling for warehouses. For example:

get(fn: (this: T) => any): SchemaTypeVirtual<T> {

Actually, it should be:

get(fn: (this: Document<T>) => any): SchemaTypeVirtual<T> {}

However, it is difficult to refactor the type due to the following implementations:

constructor(data?: T) {
if (data) {
Object.assign(this, data);
}
}

Additional context

No response

@D-Sketon
Copy link
Member Author

One possible solution is to redefine a new type, e.g:

type DocumentType<T> = Document<T> & T

Then replace Document<T> with DocumentType<T> wherever it needs to be used.
But this could be a big change.

@D-Sketon
Copy link
Member Author

I'll fix the types and try my best to solve it in the next big release

@D-Sketon
Copy link
Member Author

The situation may be more complicated than I thought, the populate method can cause the generic type to change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant