From e851ad483b00ea910c82412aec14128843bfe468 Mon Sep 17 00:00:00 2001 From: Denis Malinochkin Date: Sun, 12 Nov 2017 13:23:34 +0300 Subject: [PATCH] feat(types): Add typings for "bash-glob" package --- types/bash-glob/bash-glob-tests.ts | 21 +++++++++++++++++ types/bash-glob/index.d.ts | 36 ++++++++++++++++++++++++++++++ types/bash-glob/tsconfig.json | 23 +++++++++++++++++++ types/bash-glob/tslint.json | 1 + 4 files changed, 81 insertions(+) create mode 100644 types/bash-glob/bash-glob-tests.ts create mode 100644 types/bash-glob/index.d.ts create mode 100644 types/bash-glob/tsconfig.json create mode 100644 types/bash-glob/tslint.json diff --git a/types/bash-glob/bash-glob-tests.ts b/types/bash-glob/bash-glob-tests.ts new file mode 100644 index 0000000000..cf63412653 --- /dev/null +++ b/types/bash-glob/bash-glob-tests.ts @@ -0,0 +1,21 @@ +import bashGlob = require('bash-glob'); + +bashGlob('pattern', (err, files) => {}); +bashGlob(['pattern'], (err, files) => {}); +bashGlob(['pattern'], {}, (err, files) => {}); +bashGlob(['pattern'], { cwd: 'cwd' }, (err, files) => { }); + +bashGlob.on('match', (match, cwd) => {}); +bashGlob.on('files', (files, cwd) => {}); +bashGlob.on('end', (files) => {}); + +bashGlob.each('pattern', (err, files) => {}); +bashGlob.each(['pattern'], (err, files) => {}); +bashGlob.each(['pattern'], {}, (err, files) => {}); +bashGlob.each(['pattern'], { cwd: 'cwd' }, (err, files) => {}); + +// $ExpectType string[] +bashGlob.sync('pattern'); +bashGlob.sync(['pattern']); +bashGlob.sync(['pattern'], {}); +bashGlob.sync(['pattern'], { cwd: 'cwd' }); diff --git a/types/bash-glob/index.d.ts b/types/bash-glob/index.d.ts new file mode 100644 index 0000000000..29582ea9bd --- /dev/null +++ b/types/bash-glob/index.d.ts @@ -0,0 +1,36 @@ +// Type definitions for bash-glob 2.0 +// Project: https://github.com/micromatch/bash-glob +// Definitions by: mrmlnc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type Patterns = string | string[]; +type Callback = (err: Error, files: string[]) => void; + +declare function bashGlob(pattern: Patterns, callback: Callback): void; +declare function bashGlob(pattern: Patterns, options: bashGlob.Options, callback: Callback): void; + +declare namespace bashGlob { + interface Options { + cwd?: string; + dot?: boolean; + dotglob?: boolean; + extglob?: boolean; + failglob?: boolean; + globstar?: boolean; + nocase?: boolean; + nocaseglob?: boolean; + nullglob?: boolean; + } + + function on(event: 'match' | 'files', callback: (files: string, cwd: string) => void): void; + function on(event: 'end', callback: (files: string) => void): void; + + function each(patterns: Patterns, callback: Callback): void; + function each(patterns: Patterns, options: Options, callback: Callback): void; + + function promise(patterns: Patterns, options?: Options): Promise; + + function sync(patterns: Patterns, options?: Options): string[]; +} + +export = bashGlob; diff --git a/types/bash-glob/tsconfig.json b/types/bash-glob/tsconfig.json new file mode 100644 index 0000000000..6a45a2d74d --- /dev/null +++ b/types/bash-glob/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bash-glob-tests.ts" + ] +} diff --git a/types/bash-glob/tslint.json b/types/bash-glob/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/bash-glob/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }