cmd-ts
cmd-ts copied to clipboard
Contravariance for oneOf and defaultValue
Example
import * as cmd from "cmd-ts";
cmd.command({
name: 'regression',
args: {
target: cmd.option({
type: cmd.oneOf(['stable', 'canary']),
long: 'target',
defaultValue() {
return 'stable'; // Error
}
}),
});
TS Result: Type '() => string' is not assignable to type '() => "stable" | "canary"'.
Expected
No Error.
Accept return value: 'stable' as 'stable' | 'carary'