Urigo / WhatsApp-Clone-Client-React

https://www.tortilla.academy/Urigo/WhatsApp-Clone-Tutorial
https://tortilla.academy
613 stars 143 forks source link

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

Open igormenin opened 3 years ago

igormenin commented 3 years ago

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 commented 3 years ago

@Urigo check this report for me?

derek07 commented 3 years ago

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

eibay commented 3 years ago

@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 commented 3 years ago

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