Skip to content

Backwards-incompatible change in 10.0.9 types #173

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

Closed
nwalters512 opened this issue Aug 9, 2023 · 5 comments · Fixed by #174
Closed

Backwards-incompatible change in 10.0.9 types #173

nwalters512 opened this issue Aug 9, 2023 · 5 comments · Fixed by #174

Comments

@nwalters512
Copy link

#172 appears to disallow passing an options object without also specifying an output property. This can be reproduced with the following code:

import { filesize } from 'filesize';

const size = filesize(12345, { base: 2 });
Screenshot 2023-08-09 at 13 20 00

TypeScript playground link: https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgM2AGwKYGdgC8NwC+KUEIcA5KpjvhQNwCwAUCwMYQB2W8tBAvCnTY8GABQBGAEwBmACwBWADSI4AIwCGWDAC44UogEp6QA

If this was intentional, this should be released in a v11, as it was a breaking change. However, based on the docs, I can assume this was unintentional, as output is specified as having a default of string, and it isn't explicitly passed in the example at the top of the README. If this was indeed unintentional, I can open a PR making the following change to the types:

-export function filesize(byteCount: number, options: FileSizeOptionsString): string
+export function filesize(byteCount: number, options: FileSizeOptionsBase | FileSizeOptionsString): string
@avoidwork
Copy link
Owner

what's the best course of action for typescript users? i can revert, but I'm not going to produce a fix.

@avoidwork
Copy link
Owner

i've reverted 10.0.9 to produce 10.0.10 (equal to 10.0.8).

@avoidwork
Copy link
Owner

cc @tschlechtweg

@ghost
Copy link

ghost commented Aug 10, 2023

I overlooked that case. @nwalters512 please go ahead and create a PR with the changes you proposed, please also don't forget to then change the overloads of the partial-function.

@avoidwork
Copy link
Owner

I've reverted 10.0.9 as 10.0.10/11 (ugh) so please correct and open a new PR.

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

Successfully merging a pull request may close this issue.

2 participants