fix(ls): Allow string types for type
arg & improve type safety
#4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request delivers a set of improvements to the
ls
function, focusing on flexibility, type safety, and documentation clarity.Details
APIs Enhancements
String Value Support for
type
Argument:Previously, the
ls
function only recognizedlsTypes
enum values. This change allows you to use string literals directly corresponding tolsTypes
properties for thetype
argument. This simplifies usage, as shown in the example:Code above are equivalent with this code:
A stricter type checking mechanism has been implemented to prevent unexpected or invalid input for the
type
argument. This is further supported by the introduction of a dedicated helper function,checkType
, for robust type verification.Default Type Resolution Refactor:
This change addresses a minor internal adjustment related to the default type resolution mechanism within the
ls
function.Documentation
The API documentation for the
ls
function has been comprehensively reviewed and updated for better clarity. Additionally, link references have been added to relevant error classes that might be thrown by the API, providing more context for potential issues.Test Environments
New test cases have been added to comprehensively cover various scenarios:
null
for theoptions
argument.type
argument.TypeError
for unexpectedtype
values.This ensures the function behaves as expected under different input conditions. Additionally, this changes enhances the readability of success test case descriptions within the
simpletest
library by adjusting their text color.Benefits
type
argument.