New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add TypeScript support #1359
Comments
Take this first And a mistake I found: choice missing declare namespace yargs {
type Choices = ReadonlyArray<string | true | undefined | number>
} |
The main problem with typescript support is not to add the type definitions, but to keep them up to date with the javascript code, and to have tests to check they are. I see, from the example @bcoe gave above, that chalk is using So, in my opinion, our options are as follow:
|
@magicdawn, @mleguen, I'm looping in @nikolay-borzov who appears to have done a lot of the work on I'm wondering if our best bet would be to keep using I'm fairly new to TypeScript myself, so it would be a great learning experience for me to help pull this document together. |
I can't imagine what should be said about TypeScript in yargs' documentation. TypeScript definition file itself is a part of the documentation. |
Perhaps mentionning @types/yargs in yargs' doc, along with the npm
install command and a basic usage example, would be enough?
|
@mleguen @nikolay-borzov this was my thinking, for someone who's a relative TypeScript laymen (which is a lot of folks).
|
Well, an example of using types looks exactly like one w/o types https://github.com/danvk/source-map-explorer/blob/master/src/cli.ts#L27 |
Nuances like the fact that you've defined an interface for the /** Parsed CLI arguments */
interface Arguments {
_: string[];
json?: string;
tsv?: string;
html?: string;
onlyMapped?: boolean;
noRoot?: boolean;
replace?: string[];
with?: string[];
} And that your project will now have the It also helps direct people who finding any bugs with types towards DefinitelyTyped. |
Okay, I'll think of something and submit a PR in a week. Just to clarify my contribution to |
see: #1381 |
I would love for yargs to ship with TypeScript support.
Sindre has been shipping definitions with all of his modules, which I think is a great pattern to follow:
https://github.com/chalk/chalk/blob/master/index.d.ts
The text was updated successfully, but these errors were encountered: