- Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
I have a prototype implementation of types for this package, with some type-level shenanigans so that you get exact types on the result as long as you pass the config directly to parseArgs. E.g.:
let{ values, positionals }=parseArgs({options: {foo: {type: 'string',multiple: true},bar: {type: 'boolean'},evil: {type: 'string',multiple: Math.random()<0.5},},});letfoo: string[]=values.foo;// worksletbar: boolean|undefined=values.bar;// worksletevil: string[]|string|undefined=values.evil;// if we can't precisely infer `multiple`, we can't say if it's an array or notpositionals[0];// error: since we did not explicitly specify `allowPositionals: true`, the `positionals` array must be emptyAny feedback before I submit them upstream? You can play around with the types in the playground linked, no need to install anything.
styfle and lostfictions
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed