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

fix(ls): Allow explicit null value for options parameter #3

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

mitsuki31
Copy link
Owner

@mitsuki31 mitsuki31 commented Apr 20, 2024

Summary

This pull request addresses a type safety issue related to the options parameter in all ls* functions.

Details

Previously, the options parameter for all ls* functions was defined as non-nullable. This meant you couldn't explicitly pass null as an argument, even though using undefined or an empty object ({}) was a valid way to indicate no options.

This change updates the type definition for the options parameter to allow null as a valid value alongside undefined. This provides more flexibility in how you can use the ls* functions.

Previously if you write code like this:

const dirs = await ls('./foo', null, lsTypes.LS_D);

An error will be thrown from the internal function, with message Uncaught TypeError: Cannot read properties of null (reading 'match'). Now after this change, the issue has been fixed and can the options parameter is now nullable.

Benefits

  • Improved type safety:
    The type definition now accurately reflects the acceptable values for the options parameter.
  • Enhanced developer experience:
    Developers can now explicitly pass null to indicate no options, leading to clearer code and potentially fewer runtime errors.

Previously, the `options` parameter of all `ls*` functions cannot passed as `null`, instead it should use `undefined` or an empty object (`{}`). This change is here to address the issue, and the `options` parameter can now be passed either with `null` or `undefined` as the value.
@mitsuki31 mitsuki31 self-assigned this Apr 20, 2024
@mitsuki31 mitsuki31 added patch Patch changes (e.g., hotfix bugs and issues) refactor Refactor changes bugfix Bug or issue fixes labels Apr 20, 2024
@mitsuki31 mitsuki31 merged commit 6c8a65e into master Apr 20, 2024
3 checks passed
@mitsuki31 mitsuki31 deleted the fix/options-parameter-non-nullable branch April 20, 2024 04:12
@mitsuki31 mitsuki31 added this to the v1.0.0 milestone Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug or issue fixes patch Patch changes (e.g., hotfix bugs and issues) refactor Refactor changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant