Skip to content

Using createSelector with EntityAdapter's getSelectors causes '$CombinedState' error #2068

@akramhussein

Description

@akramhussein

Problem

When using the EntityAdapter's exported selectors with reselects createSelector a Typescript error is thrown regarding the $CombinedState symbol not being exported.

Example:

import { createSelector } from '@reduxjs/toolkit'

import { sessionsAdapter } from '../reducers/sessions'
import { RootState } from '../types'

export const { selectAll: selectAllSessions } = sessionsAdapter.getSelectors((state: RootState) => state.sessions)
export const currentSessionSelector = createSelector(selectAllSessions, (sessions) => sessions[0])

Results in the following error

Exported variable 'currentSessionSelector' has or is using name '$CombinedState' from external module "../node_modules/redux/index" but cannot be named.ts(4023)

Package Versions

Current:

  • typescript 4.5.5
  • redux 4.1.2
  • @reduxjs/toolkit 1.7.2
  • react-redux 7.2.6

This code was previously working with the following package versions:

Previous:

  • typescript 4.4.3
  • redux 4.1.2
  • @reduxjs/toolkit 1.6.1
  • react-redux 7.2.6

I'm not sure at which point it broke as I upgraded to the latest and I'm now working backwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions