github reduxjs/reselect v4.1.0-alpha.0

latest releases: v5.1.1, v5.1.0, v5.0.1...
pre-release3 years ago

This alpha preview release rewrites the TypeScript types to target TypeScript 4.2+, adds automatic type inference for createStructuredSelector, fixes a longstanding bug with the equalityCheck argument to defaultMemoize and its usage with createSelectorCreator, and updates build tooling.

npm i reselect@next

yarn add reselect@next

This is the first release in several years, due to the original maintainer @ellbee dealing with other obligations. Thanks to him for all his hard work, and for giving additional maintainers access.

We have an open roadmap discussion asking for feedback on a potential Reselect v5 API design, and would appreciate additional input and ideas there.

Changelog

TypeScript Target Version Updated to 4.2+

The Reselect types were written several years ago and originally targeted TS 2.x versions. As a result, the typedefs requires dozens of overloads to handle varying numbers of arguments (see the legacy typedefs file for examples).

We've completely rewritten the TS typedefs to use modern TS syntax like mapped types. This drastically shrinks the size of the typedefs (from 1000 lines to about 115), and also improves the actual type inference overall.

The updated types do require use of TS 4.2+. We've attempted to keep the final public type names and usage the same, but there may also be some types breakage. We'd appreciate feedback on any meaningful breakage issues so we can make further tweaks if needed.

Given the intent of the improvements, that they're all type-only changes, the attempts to retain backwards compatibility, and TS's own versioning scheme, we're considering this to be a minor version change rather than a major.

The legacy types are still included, and should automatically be used if you are using TS 4.1 and earlier.

Additional Type Fixes

In some cases passing an equalityCheck function to defaultMemoize would not infer the right types for the (a, b) arguments, either when used by itself or as an argument to createSelectorCreator. Those types should now be inferred correctly.

As part of that work, the types had long declared that equalityCheck functions took index: number as a third parameter. That has not been true in the actual JS code since late 2016, but the types weren't updated to match the runtime behavior. That is now fixed.

A new overload of createSelectorCreator has been added that will infer the type of state for the overall selector if all input selectors have the state argument typed.

Build Tooling Updates

Reselect now (finally) uses Babel 7. We're using Github Actions for CI and running type tests against TS4.2+.

Changes

This alpha release is from a still-draft PR, #486, and contains code from:

Full Changelog: v4.0.0...v4.1.0-alpha.0

Don't miss a new reselect release

NewReleases is sending notifications on new releases.