question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript error: Type 'unknown' is not assignable to type 'never'

See original GitHub issue

What is the current behavior?

Redux set never as type instead of unknown:

The types of ‘router.location.state’ are incompatible between these types. Type ‘unknown’ is not assignable to type ‘never’.

Steps to Reproduce

import { connectRouter, LocationChangeAction, RouterState } from 'connected-react-router';
import { History } from 'history';
import { applyMiddleware, combineReducers, compose, createStore, Store, CombinedState, AnyAction } from 'redux';

export type ApplicationState = { router: RouterState };

const createRootReducer = (history: History) => combineReducers({
    router: connectRouter(history),
});

export default function configureStore(history: History, initialState?: ApplicationState): Store<CombinedState<any>, AnyAction | LocationChangeAction<any>> {
    const store = createStore(
        createRootReducer(history), // root reducer with router state
        initialState,
    );

    return store;
}

What is the expected behavior?

Use unknown instead of never

Environment Details

Redux 4.1.0 Chrome Windows 10 Did this work in previous versions of Redux? Yes

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
phryneascommented, May 3, 2021

Please see if https://github.com/reduxjs/redux/pull/4078 resolves your issue

0reactions
jucrouzetcommented, May 30, 2021

I encountered the same issue and #4078 fixes it.

Thanks @phryneas waiting for the PR to be merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is "not assignable to parameter of type never" error in ...
The reason was that the array was initialised with also the option of an empty array. Typescript saw a push to a type...
Read more >
Argument of type not assignable to parameter type 'never'
The error "Argument of type is not assignable to parameter of type 'never'" occurs when we declare an empty array without explicitly typing...
Read more >
Typescript `never` type - Explain Programming
The error which got me to learn more about never : Here Typescript says. Argument of type 'string[]' is not assignable to parameter...
Read more >
What is not assignable to parameter of type never error in ...
Your answer​​ All you have to do is define your result as a string array, like this: const result : string[] = [];...
Read more >
Type 'any' is not assignable to type 'never' with boolean in ...
Most instances of this error represent potential errors in the relevant code. If you are convinced that you are not dealing with an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found