arg icon indicating copy to clipboard operation
arg copied to clipboard

Make typings more type-friendly

Open auguwu opened this issue 2 years ago • 0 comments

This PR is basically a small modification to the typings of this package, I basically added 2 new types to help TypeScript users define the arg specification more clearly.

Right now, you would need to define an interface prefixed with -- which is not common at all when writing interfaces:

import arg from 'arg';

interface CliArgs extends arg.Spec {
  '--key': string;
}

arg<CliArgs>({
  // Success!
  '--key': String
});

In this PR, this basically converts all the keys from the T generic from the default exports prefixed with dashes:

import arg from 'arg';

interface CliArgs extends arg.Spec {
  key: string;
}

arg<CliArgs>({
  // Success!
  '--key': String
});

Sorry for the bad writing, I'm not really good at explaining what I did within PRs (since I'm not usually a contributor on most repositories.)

auguwu avatar Nov 06 '21 03:11 auguwu