clo4 / run-fig

Build fast (as in, the fastest) command-line apps with JS/TS
https://doc.deno.land/https://denopkg.com/SeparateRecords/run-fig/mod.ts
MIT License
3 stars 0 forks source link

Type safety #6

Open clo4 opened 1 year ago

clo4 commented 1 year ago

You can use options.get("not an option") and TS won't tell you there's a mistake, because actions currently cannot know their options or args statically.

Blocked on parser generator. Can generate types too.

clo4 commented 1 year ago

Not blocked on parser generator. I think I'll do this with an API like:

const spec = Fig.infer({
  name: "...",
});

Fig.run(spec);

You can of course write it directly in Fig.run but that's a bit of an antipattern.

I'm thinking this will do something more specific than Fig.Spec etc. Instead it will use something like Fig.InferredSpec which has a shitload of generics on it that Fig.infer will infer for you. It has to be a function param atm, generics can't be inferred on an assignment :(

clo4 commented 1 year ago

This is not possible, because of nesting subcommands. TS doesn't support this as a pattern