diff --git a/types/dir-glob/dir-glob-tests.ts b/types/dir-glob/dir-glob-tests.ts new file mode 100644 index 0000000000..e8aaf721dc --- /dev/null +++ b/types/dir-glob/dir-glob-tests.ts @@ -0,0 +1,23 @@ +import dirGlob = require('dir-glob'); + +dirGlob('index.js').then(files => { + // ExpectType string[] + files; +}); +dirGlob(['index.js', 'test.js', 'fixtures']).then(files => { + // ExpectType string[] + files; +}); + +dirGlob(['index.js', 'inner_folder'], { cwd: 'fixtures' }); +dirGlob(['lib/**', 'fixtures'], { files: ['test', 'unicorn'] }); +dirGlob(['lib/**', 'fixtures'], { extensions: ['js'] }); + +// ExpectType string[] +dirGlob.sync('index.js'); +// ExpectType string[] +dirGlob.sync(['index.js', 'test.js', 'fixtures']); + +dirGlob.sync(['index.js', 'inner_folder'], { cwd: 'fixtures' }); +dirGlob.sync(['lib/**', 'fixtures'], { files: ['test', 'unicorn'] }); +dirGlob.sync(['lib/**', 'fixtures'], { extensions: ['js'] }); diff --git a/types/dir-glob/index.d.ts b/types/dir-glob/index.d.ts new file mode 100644 index 0000000000..c1e78ae111 --- /dev/null +++ b/types/dir-glob/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for dir-glob 2.0 +// Project: https://github.com/kevva/dir-glob#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = dirGlob; + +declare function dirGlob(input: string | string[], options?: dirGlob.Options): Promise; + +declare namespace dirGlob { + function sync(input: string | string[], options?: Options): string[]; + + interface Options { + extensions?: string[]; + files?: string[]; + cwd?: string; + } +} diff --git a/types/dir-glob/tsconfig.json b/types/dir-glob/tsconfig.json new file mode 100644 index 0000000000..2cf8fd31d8 --- /dev/null +++ b/types/dir-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", + "dir-glob-tests.ts" + ] +} diff --git a/types/dir-glob/tslint.json b/types/dir-glob/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/dir-glob/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }