#586·reselect

`createSelector` signature with additional parameters doesn't preserve names

Author: NordlingDevCreated Oct 13, 2022Updated Mar 18, 2026
LabelsTypeScript

The inferred type of a selector instance doesn't preserve the extra parameters' names. Instead they are called params_0, params_1, etc... See example below:

typescript
type Item = {
  id: string;
  name: string;
};

type State = {
  items: Record<string, Item>;
};

export const selectItemById = createSelector(
  (state: State, itemId: string) => state.items[itemId] || null,
  (item) => item,
);

The inferred type signature of this selector becomes:

typescript
const selectItemById: (state: State, params_0: string) => Item | null

As you can see, parameter itemId is now called params_0. From a consumer perspective, this parameter is ambiguous and impossible to understand. How can this be fixed? I honestly don't think I'm doing anything wrong here.

Version: 4.1.6