avoidwork/filesize.js

[TypeScript] Return type reported to be incorrect when changing output type from the default

alpha-tango-kilo opened this issue · 4 comments

Using TypeScript, I'm told that the following will return a string, which isn't correct:

fileSize(123123, { output: "object" });

What I expect to be able to do:

let { value, symbol, exponent } = fileSize(123123, { output: "object" });

Current workaround:

let { value, symbol, exponent } = fileSize(123123], { output: "object" }) as unknown as { value: number, symbol: string, exponent: number };

For clarity, it is actually an object that gets returned, just the type declarations are telling me I'm going to get a string

Upon further usage, it seems the same seems to apply for all the different output options - they all say they're going to return string

File was lifted from https://github.com/DefinitelyTyped/DefinitelyTyped; I didn't write it. Feel free to open a PR with fix or updated from that repo.

@avoidwork do you know even whatsapp web uses your code?

@bhavya32 cool; i didn't.