Open
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 },
},
});
let foo: string[] = values.foo; // works
let bar: boolean | undefined = values.bar; // works
let evil: string[] | string | undefined = values.evil; // if we can't precisely infer `multiple`, we can't say if it's an array or not
positionals[0]; // error: since we did not explicitly specify `allowPositionals: true`, the `positionals` array must be empty
Any feedback before I submit them upstream? You can play around with the types in the playground linked, no need to install anything.