fastapi-react icon indicating copy to clipboard operation
fastapi-react copied to clipboard

'unknown' is not assignable to parameter of type 'SetStateAction<string>'.

Open treize06 opened this issue 4 years ago • 5 comments

When launching docker compose up and then going to localhost:8000, I got the following error:

/app/src/views/Login.tsx TypeScript error in /app/src/views/Login.tsx(54,18): Argument of type 'unknown' is not assignable to parameter of type 'SetStateAction'. Type 'unknown' is not assignable to type '(prevState: string) => string'. TS2345

52 |       } else {
53 |         // handle errors thrown from backend

54 | setError(err); | ^ 55 | } 56 | } 57 | };

treize06 avatar Sep 01 '21 20:09 treize06

first time using TS so I thought it was just me -- am getting the same error

rxnel avatar Sep 01 '21 23:09 rxnel

You can try changing the strict setting in frontend/tsconfig.json to false.

felixthebeard avatar Sep 03 '21 18:09 felixthebeard

thanks its working now

treize06 avatar Sep 06 '21 14:09 treize06

      } else {
        // handle errors thrown from backend
        setError(String(err));
      }

Cast does the trick

JosXa avatar Sep 11 '21 00:09 JosXa

I'll merge a PR if you want to make one for this?

Buuntu avatar Sep 21 '21 01:09 Buuntu