https://github.com/nuxt/cli/pull/381 inspired me to work on this PR, as I noticed the args can be undefined at runtime even though their types do not reflect this.
โ Type of change
[ ] ๐ Documentation (updates to the documentation, readme, or JSdoc annotations)
[ ] ๐ Bug fix (a non-breaking change that fixes an issue)
[ ] ๐ Enhancement (improving an existing functionality like performance)
[ ] โจ New feature (a non-breaking change that adds functionality)
[ ] ๐งน Chore (updates to the build process or auxiliary tools and libraries)
[x] โ ๏ธ Breaking change (fix or feature that would cause existing functionality to change)
๐ Description
This PR:
defines the exact set of available properties based on the arg type
defines a relationship between required and default properties
adjust the types of ctx.args.<arg> based on default and required property (currently, ctx.args.<arg> is never undefined)
inferres the exact possible values for an enum arg when accessing via ctx.args.<arg> (e.g. 1 | 2 | 3 rather than number)
improves how we handle resolving aliases assigned to parseOptions.alias
๐ Linked issue
https://github.com/nuxt/cli/pull/381 inspired me to work on this PR, as I noticed the args can be
undefined
at runtime even though their types do not reflect this.โ Type of change
๐ Description
This PR:
required
anddefault
propertiesctx.args.<arg>
based ondefault
andrequired
property (currently,ctx.args.<arg>
is neverundefined
)ctx.args.<arg>
(e.g.1 | 2 | 3
rather thannumber
)parseOptions.alias
๐ Checklist