Closed greenpau closed 1 year ago
That file is generated; tsc bug? Considering this issue is entirely imaginary, what is the suggested problem/solution?
That file is generated; tsc bug?
Yes. There is some difference between React 17 and React 18 handling of the filesize
module.
does the type file for earlier versions work? the persons chose a diff structure than tsc generates.
@avoidwork , yes. I was using filesize with react 17 and things worked just fine.
@greenpau are you using @types/react 18.0.0? from what i'm reading this has nothing to do with filesize and simply relates to the optional object output.
I ran into the same problem. The main problem is that the return type from the filesize()
function can be of the following types:
string | number | any[] | {
value: any;
symbol: any;
exponent: number;
unit: string;
};
If you want to use the result of the filesize()
function inside a JSX element, the expected type is a string, integer, or iterable, which does not quite match the defined type of object. @avoidwork is it beneficial to combine these different types, or could we split them into separate functions to prevent the mismatch with ReactNode
?
I was able to fix the type error by just parsing the result to a string (like filesize().toString()
). But that solution is not as pretty as I would like it.
After the upgrade to React 18, I started getting the following Typescript errors: