Add types for copy

This commit is contained in:
Florian Keller
2019-01-24 15:45:59 +01:00
parent d5fe4dcadb
commit ea6c34ee9b
4 changed files with 90 additions and 0 deletions
+35
View File
@@ -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
});
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for copy 0.3
// Project: https://github.com/jonschlinkert/copy
// Definitions by: Florian Keller <https://github.com/ffflorian>
// 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;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }