WhatsApp-Clone-Client-React icon indicating copy to clipboard operation
WhatsApp-Clone-Client-React copied to clipboard

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

Open igormenin opened this issue 4 years ago • 4 comments

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<PoorMansUnknown>'. 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 avatar Sep 20 '20 16:09 igormenin

@Urigo check this report for me?

igormenin avatar Sep 21 '20 18:09 igormenin

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

derek07 avatar Oct 04 '20 05:10 derek07

@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

eibay avatar Oct 27 '20 21:10 eibay

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

JP-1997 avatar Mar 01 '21 12:03 JP-1997