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

Type and runtime checks for default and validOptions combos #18

Merged
merged 9 commits into from
Sep 23, 2024

Conversation

lukekarrys
Copy link
Contributor

@lukekarrys lukekarrys commented Aug 15, 2024

This PR does a few things in the name of increasing type and runtime checks for fields with the full combination of default and validOptions across different type and multiple combinations. Fixes #17

Some other notable items:

  • Refreshes the lockfile
  • Removes the parseArgs shims since all supported Node versions have it natively
  • Creates a new test file to test all these scenarios
  • Reorders index.ts so all types are at the top with isType functions below their type counterpart
  • Consolidate the types and code paths for initializing fields via addFields/opt/optList/num/numList/flag/flagList so they all get the same behavior

Some possible breaking changes due to some of the above refactoring:

  • type MultiType is gone since it was no longer needed in the same way
  • Renamed type ConfigOptionBase is now type ConfigOption. This is maybe a bit arbitrary but I think matches better to how it is used.
  • Changed the optional/required-ness of some generic type arguments

@lukekarrys lukekarrys changed the title lk/validate default valid options 2 Valid options and defaults types/checks Aug 16, 2024
@lukekarrys
Copy link
Contributor Author

lukekarrys commented Aug 16, 2024

TODO:

  • export all types
  • fix how this handles the case of multiple:true with default values not being narrowed properly
  • fix case where flags with defaults are made optional

@lukekarrys lukekarrys force-pushed the lk/validate-default-valid-options-2 branch from d048f82 to 3f08164 Compare August 16, 2024 22:26
@lukekarrys lukekarrys changed the title Valid options and defaults types/checks Type and runtime checks for default and validOptions combos Aug 19, 2024
@lukekarrys lukekarrys force-pushed the lk/validate-default-valid-options-2 branch 2 times, most recently from fad3f72 to 3f729ea Compare August 19, 2024 17:42
@lukekarrys lukekarrys force-pushed the lk/validate-default-valid-options-2 branch from 3f729ea to 6e96ca1 Compare August 19, 2024 17:51
@lukekarrys lukekarrys force-pushed the lk/validate-default-valid-options-2 branch from 6e96ca1 to c81ea16 Compare August 19, 2024 18:20
@lukekarrys lukekarrys mentioned this pull request Aug 19, 2024
@isaacs isaacs force-pushed the lk/validate-default-valid-options-2 branch from c81ea16 to 3abd065 Compare September 23, 2024 18:53
@isaacs isaacs closed this in 3abd065 Sep 23, 2024
@isaacs isaacs merged commit 3abd065 into isaacs:main Sep 23, 2024
8 checks passed
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 this pull request may close these issues.

Enforce default to be a member of validOptions
2 participants