Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type 'History<unknown>' is not assignable to type 'History<PoorMansUnknown>'. #1587

Open
igormenin opened this issue Sep 20, 2020 · 4 comments

Comments

@igormenin
Copy link

after starting the project, the browser loaded the login screen, but immediately afterwards it showed the error below:

Failed to compile

/home/igormenin/Documentos/Desenvolvimento/testevenombots/WhatsApp-Clone-Client-React/src/App.tsx
TypeScript error in /home/igormenin/Documentos/Desenvolvimento/testevenombots/WhatsApp-Clone-Client-React/src/App.tsx(26,58):
Type 'History' is not assignable to type 'History'.
The types of 'location.state' are incompatible between these types.
Type 'unknown' is not assignable to type 'PoorMansUnknown'.
Type 'unknown' is not assignable to type '{}'. TS2322

24 |         component={withAuth(
25 |           ({ match, history }: RouteComponentProps<{ chatId: string }>) => (
26 |             <ChatRoomScreen chatId={match.params.chatId} history={history} />
   |                                                          ^
27 |           )
28 |         )}
29 |       />

This error occurred during the build time and cannot be dismissed.

@igormenin
Copy link
Author

@Urigo check this report for me?

@derek07
Copy link

derek07 commented Oct 4, 2020

@igormenin @Urigo Same issue for me. Let me know here if you find a solution.

@eibay
Copy link

eibay commented Oct 27, 2020

@igormenin : The temporary fix I made to be able to get rid of the error is to modify the file in the node_modules.
Goto node_modules/@types/history/index.d.ts and added "unknown" in line 49 as another option.
type PoorMansUnknown = {} | null | undefined | unknown;

I am not sure how to implement this as a pull request and where to file it. @Urigo

@JP-1997
Copy link

JP-1997 commented Mar 1, 2021

import History from 'history'; will result to this issue. History is a named export and hence import { History } from 'history'; is the correct way to go.
Hope this solves your issue ; - ) @igormenin @derek07 @eibay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants