reselect: TypeScript types appear to be broken in 4.1.5

When upgrading from 4.1.4 to 4.1.5, we started seeing a bunch of TypeScript complaints:

spec/javascript/responses/selectors_spec.ts:120:29 - error TS2322: Type '{ responses: { is_selected: boolean; }[]; are_all_selected_across_pages: boolean; meta: { pagination: { total_count: number; }; }; campaign_data: { doc_pages_count: number; }; }' is not assignable to type 'never'.

120     expect(canGeneratePdf({ responses })).toBe(true);
                                ~~~~~~~~~
const canGeneratePdf = createSelector([getSelectedResponsesCount], (selected_responses_count) => {
  const can_bulk_download_pdf = Feature.isActive('responses/bulk_download_pdf');

  return can_bulk_download_pdf || selected_responses_count <= default_page_size;
});

Not sure why the type never is being inferred from the arguments.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 32 (14 by maintainers)

Commits related to this issue

Most upvoted comments

My immediate assumption would be that trying to mix and match selectors created with 4.1.x and 4.0 would be incompatible, because of the completely different TS type definitions. I would strongly recommend trying to get this internal library updated to use 4.1.x, which has much better TS inference overall.

(that said I’m also still not really sure what you mean by “targets 4.0” - there should only be one copy of Reselect installed in your application’s node_modules, right?)

Okay, yeah, that’s the first issue. Per several other recent issue threads, the current Reselect types expect that TS strict checks are turned on, and will very likely produce incorrect results if that’s turned off.