Create types for sade (#40398)

This commit is contained in:
Frederic 2019-11-15 00:45:45 +01:00 committed by Pranav Senthilnathan
parent 6061d28041
commit a2149e0650
4 changed files with 77 additions and 0 deletions

33
types/sade/index.d.ts vendored Normal file
View File

@ -0,0 +1,33 @@
// Type definitions for sade 1.6
// Project: https://github.com/lukeed/sade#readme
// Definitions by: Epimodev <https://github.com/Epimodev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as mri from 'mri';
type Handler = (...args: any[]) => void;
declare namespace sade {
interface CommandOptions {
default?: boolean;
}
interface ParseOptions extends mri.Options {
lazy?: boolean;
}
interface Sade {
command(str: string, desc?: string, opts?: Readonly<CommandOptions>): Sade;
describe(str: string | ReadonlyArray<string>): Sade;
option(str: string, desc: string, val?: string | number): Sade;
action(handler: Handler): Sade;
example(str: string): Sade;
version(str: string): Sade;
parse(arr: string[], opts?: Readonly<ParseOptions>): { args: string[]; name: string; handler: Handler } | void;
help(str: string): void;
}
}
declare function sade(str: string, isOne?: boolean): sade.Sade;
export = sade;

20
types/sade/sade-tests.ts Normal file
View File

@ -0,0 +1,20 @@
import sade = require('sade');
const prog = sade('my-cli');
const argv = ['sirv', 'build'];
prog.version('1.0.5')
.option('--global, -g', 'An example global flag')
.option('-c, --config', 'Provide path to custom config', 'foo.config.js');
prog.command('build <src> <dest>')
.describe('Build the source directory. Expects an `index.js` entry file.')
.option('-o, --output', 'Change the name of the output file', 'bundle.js')
.example('build src build --global --config my-conf.js')
.example('build app public -o main.js')
.action((src: any, dest: any, opts: any) => {});
prog.help('build');
prog.parse(argv);

23
types/sade/tsconfig.json Normal file
View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"sade-tests.ts"
]
}

1
types/sade/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }