diff --git a/types/copy/copy-tests.ts b/types/copy/copy-tests.ts new file mode 100644 index 0000000000..c72ad3532a --- /dev/null +++ b/types/copy/copy-tests.ts @@ -0,0 +1,35 @@ +import copy = require('copy'); +import File = require('vinyl'); + +copy.each(['a', 'b'], '.', { cwd: '..' }, () => {}); +copy.each(['a', 'b'], '.', { cwd: '..' }, (error, files) => { + error; // $ExpectType Error | null + files; // $ExpectType File[] | undefined +}); +copy.each(['a', 'b'], '.', () => {}); +copy.each(['a', 'b'], '.', (error, files) => { + error; // $ExpectType Error | null + files; // $ExpectType File[] | undefined +}); + +copy.one('a', '.', { cwd: '..' }, () => {}); +copy.one('a', '.', { cwd: '..' }, (error, files) => { + error; // $ExpectType Error | null + files; // $ExpectType File[] | undefined +}); +copy.one('a', '.', () => {}); +copy.one('a', '.', (error, files) => { + error; // $ExpectType Error | null + files; // $ExpectType File[] | undefined +}); + +copy(['a', 'b'], '.', { cwd: '..' }, () => {}); +copy(['a', 'b'], '.', { cwd: '..' }, (error, files) => { + error; // $ExpectType Error | null + files; // $ExpectType File[] | undefined +}); +copy(['a', 'b'], '.', () => {}); +copy(['a', 'b'], '.', (error, files) => { + error; // $ExpectType Error | null + files; // $ExpectType File[] | undefined +}); diff --git a/types/copy/index.d.ts b/types/copy/index.d.ts new file mode 100644 index 0000000000..175a07e216 --- /dev/null +++ b/types/copy/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for copy 0.3 +// Project: https://github.com/jonschlinkert/copy +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import File = require('vinyl'); + +declare namespace copy { + function each(files: string[], dir: string, options: Options, callback: Callback): void; + function each(files: string[], dir: string, callback: Callback): void; + function one(pattern: string | object, dir: string, options: Options, callback: Callback): void; + function one(pattern: string | object, dir: string, callback: Callback): void; + + type Callback = (error: Error | null, files?: File[]) => void; + + interface Options { + cwd?: string; + srcBase?: string; + } +} + +declare function copy( + patterns: string | object | string[], + dir: string, + options: copy.Options, + callback: copy.Callback, +): void; +declare function copy(patterns: string | object | string[], dir: string, callback: copy.Callback): void; + +export = copy; diff --git a/types/copy/tsconfig.json b/types/copy/tsconfig.json new file mode 100644 index 0000000000..0b3e1bd3d3 --- /dev/null +++ b/types/copy/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", + "copy-tests.ts" + ] +} diff --git a/types/copy/tslint.json b/types/copy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/copy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }