Skip to content

Backwards-incompatible change in 10.0.9 types #173

@nwalters512

Description

@nwalters512

#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions