arcanis / clipanion

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

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

Open sergei-dyshel opened 1 month ago

sergei-dyshel commented 1 month 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"