reduxjs / reselect

Selector library for Redux
MIT License
19.04k stars 670 forks source link

The type of `createSelector` in ts4.1 doesn't support `memoizeOptions` as the last parameter #580

Closed Yupeng-li closed 2 years ago

Yupeng-li commented 2 years ago

Hi,

I got TS2769: No overload matches this call when I followed this example in docs.

// Selector behavior can be customized
const customizedSelector = createSelector(
  state => state.a,
  state => state.b,
  (a, b) => a + b,
  {
    // New in 4.1: Pass options through to the built-in `defaultMemoize` function
    memoizeOptions: {
      equalityCheck: (a, b) => a === b,
      maxSize: 10,
      resultEqualityCheck: shallowEqual
    }
  }
)

The type defined in this file ./src/typesVersions/ts4.1/index.d.ts doesn't support memoizeOptions

Am I missing something or does it need to be fixed?

Thank you

markerikson commented 2 years ago

What version of TS are you using? Can you put together a project that shows this happening?

If you really are on a TS version of 4.1 or earlier: yes, the old TS types do not support the new memoizeOptions field. Those types were incredibly long and copy-pasted, and there's no possible way we could have updated them. Please update to a newer version of TS, which will cause the current typedefs to be used.

Yupeng-li commented 2 years ago

Hi @markerikson,

Thank you for the quick reply. Yes, we are using typescript 4.1.6. I'll see if we can use the newer version of TS.