michaelbromley / ngx-pagination

Pagination for Angular
http://michaelbromley.github.io/ngx-pagination/
MIT License
1.21k stars 245 forks source link

error TS2345: Argument of type 'IQuestion[] | null' is not assignable to parameter of type 'Collection<unknown>'. #392

Open giovannidias1 opened 1 year ago

giovannidias1 commented 1 year ago

=======

Angular version: 13..3.2

ngx-pagination version: 6.0.2

Description of issue: I trying to add psgintion with return of store

Steps to reproduce: just add paginate pipe

Expected result: items

Actual result: error

Any relevant code:

      <app-question-card
        *ngFor="
          let question of questions$
            | async
            | paginate
              : {
                  id: 'custom',
                  itemsPerPage: 10,
                  currentPage: 1,
                  totalItems: 100
                }
        "
        [question]="question"></app-question-card>
// ts of ngfor
  questions$: Observable<IQuestion[]> = new Observable();
  [...]
  this.questions$ = this.store.select(selectRecentsQuestionsAnswers);
 // app-question-card  question input
  @Input() question!: IQuestion;
michaelbromley commented 1 year ago

Hi, can you create a minimal reproduction of this?

naveendharnamoni commented 1 year ago

I have fixed this issue by adding a non-null assertion operator in Typescript. you can add the '!' operator at the end of your array or collection. Example: let question of questions!

Another way is by turning off strictNullChecks in your tsconfig.json