-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
TypeScript definitions #27
Comments
I'm not good at TS but something like that would work? declare module 'sade' {
interface CommandOptions {
default: boolean;
}
interface MriOptions {
alias: { [key: string]: any };
string: string[];
boolean: string[];
default: { [key: string]: any };
}
type ParseOptions = { lazy: boolean } & MriOptions;
type Action = (...args: any) => any;
interface Sade {
command(str: string, desc: string, opts: CommandOptions): Sade;
describe(str: string): Sade;
option(str: string, desc: string, val: any): Sade;
action(handler: Action): Sade;
example(str: string): Sade;
version(str: string): Sade;
parse(arr: string[], opts: ParseOptions): any;
}
} |
For a project like sade, I would much rather they live inside DefintelyTyped, espeically since The If If you want to PR into DT, I'll help review and get them in! |
Hello, |
Hello @lukeed I've just made a PR into DefintelyTyped for TypeScript users: DefinitelyTyped/DefinitelyTyped#40398 I check the documentation and the source code to create it but I may have made some mistakes. |
The PR was already reviewed and merged by a DefinitelyTyped maintainer. It works well for me but I still interested in having a review from you. |
Closed via 9171cbf Sade will ship its own type definitions starting with Thank you to @Epimodev who filled in w/ the Most notable difference (I think) is that your commands' sade('hello')
.command('foobar <name> [age]', 'asd', {
default: true
})
.action<[string, number|null]>((name, age, options) => {
name.length;
// ^? type: string
age
// ^? type: number | null
options
// ^? type: mri.Argv<Default>
})
// ... |
Ooops, one more issue :D
I may PR soon.
The text was updated successfully, but these errors were encountered: