arcanis / clipanion

Type-safe CLI library / framework with no runtime dependencies
https://mael.dev/clipanion/
1.12k stars 65 forks source link

Option's default value is not tested against validator #166

Open sergei-dyshel opened 3 months ago

sergei-dyshel commented 3 months ago

I would expect TS compiler to warn me when defining e.g.:

  choice = Option.String("--choice", "d", {
    description: "Choice option",
    validator: t.isEnum(["a", "b", "c"] as const),
  });

that "d" does not pass validation, resulting in this error during runtime:

Usage Error: Invalid value for choice: expected one of "a", "b", or "c" (got "d"