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

Losing Type on applying pagination pipe #303

Closed
johnfrades opened this issue Jun 10, 2019 · 4 comments
Closed

Losing Type on applying pagination pipe #303

johnfrades opened this issue Jun 10, 2019 · 4 comments

Comments

@johnfrades
Copy link

=======

Angular version:
7.1.4

ngx-pagination version:
3.2.1

Description of issue:
I lose type when i put "| paginate" on ngFor, because the PaginationPipe is on any type.
I just wanna ask is there any other way to implement the pagination? its not really a problem at all but it kinda sucks that we gonna lose the type on the HTML

Thank you!

@michaelbromley
Copy link
Owner

michaelbromley commented Jun 10, 2019

Hi,

I guess the solution should just be to update the signature of the PaginatePipe.transform() method to be generic, i.e.

public transform<T = any>(collection: T[] | ReadonlyArray<T>, args: any): T[] {
 // ..
}

You could try manually editing the d.ts file in your node_modules to the above and see if that then fixes it for you. If so I could include the change in a new version. Alternatively if you'd like to have a go at submitting a pull request, please feel free.

@johnfrades
Copy link
Author

Hey man, i tried it and it work, but this code

transform<T = any>(collection: T[], args: any): T[];

@michaelbromley
Copy link
Owner

Did the ReadonlyArray<T> part cause an issue? It is there because some people use read only arrays in their components, and without it as part of the collection arg type, this can lead to ts errors.

@johnfrades
Copy link
Author

Yes man, sorry i put it back and everything works fine.
Thanks! i've sent a pull request

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

2 participants