Closed hosseinmd closed 1 year ago
What are you trying to do? First, those type
values are not valid, even without the "or". Second, how would it be able to decide which type to use?
Imagine I have an argument which gets two values "local" or "global".
You didn't answer all my questions.
how would it be able to decide which type to use?
I don't familiar with meow project but on Typescript, we could do it like this:
function example<T>(type: T): T extends ReadonlyArray<infer K> ? K : T {
return "" as any;
}
example(["foo", "bar"] as const) === "foo";
// example return 'foo' | 'bar
Ok, I get it now. The type
should still be a string
though. What you want is something like .choices()
in Yargs: http://yargs.js.org/docs/#choices Basically, specify a list of the possible values to the flag.
That's not supported today, but I'll mark this as a feature request.
If anyone wants to work on this, see the initial attempt in https://github.com/sindresorhus/meow/pull/183 (Also make sure you intend to finish it!)
I want to define a type like this:
How this possible? or if that is not possible. could you implement it?