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

Allow readonly string arrays in types.enumeration #2059

Merged
merged 2 commits into from
Aug 28, 2023

Conversation

jamonholmgren
Copy link
Collaborator

Overview

This PR enhances the enumeration function types to accept both mutable (string[]) and immutable (readonly string[]) string arrays. This allows for better compatibility with as const syntax and provides a more flexible API for users.

Fixes #1314.

Changes

  • Updated the type signatures in the enumeration function to handle both readonly string[] and string[].
  • Added new test cases to verify support for readonly string[] as well as maintaining support for string[].

Impact

These changes enable developers to use as const syntax with the enumeration function without any type errors, providing a smoother development experience.

Testing

New tests have been added to ensure that both readonly and plain string arrays are handled correctly. Note that tests don't seem to fail even when the typescript changes haven't been implemented, but there is a type error in the test in VS Code that goes away once this is implemented.

CleanShot 2023-08-09 at 15 05 05@2x

@jamonholmgren jamonholmgren added the Typescript Issue related to Typescript typings label Aug 9, 2023
@coolsoftwaretyler
Copy link
Collaborator

Hey @jamonholmgren - this looks good to me and makes sense! I'm gonna merge it and include in the second RC for 5.2.0.

@coolsoftwaretyler coolsoftwaretyler merged commit 9757a73 into master Aug 28, 2023
1 check passed
@coolsoftwaretyler coolsoftwaretyler deleted the fix/enumeration-as-const branch August 28, 2023 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue related to Typescript typings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Take a readonly array when possible
2 participants