Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alpha-tango-kilo opened this issue Apr 10, 2021 · 4 comments

Comments

@alpha-tango-kilo
Copy link

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

@alpha-tango-kilo
Copy link
Author

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

@alpha-tango-kilo alpha-tango-kilo changed the title Return type reported to be incorrect when outputting object [TypeScript] Return type reported to be incorrect when changing output type from the default Apr 10, 2021
@avoidwork
Copy link
Owner

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.

@bhavya32
Copy link

bhavya32 commented Jun 8, 2021

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

@avoidwork
Copy link
Owner

@bhavya32 cool; i didn't.

alpha-tango-kilo added a commit to alpha-tango-kilo/Siphon that referenced this issue Oct 18, 2021
Instead of always being in bytes, will now scale to higher units
depending on data
Two bug reports filed on GitHub:
avoidwork/filesize.js#126
chartjs/Chart.js#8873
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants