Typescript error: Type 'unknown' is not assignable to type 'never'
See original GitHub issueWhat 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:
- Created 2 years ago
- Reactions:2
- Comments:11 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please see if https://github.com/reduxjs/redux/pull/4078 resolves your issue
I encountered the same issue and #4078 fixes it.
Thanks @phryneas waiting for the PR to be merged.