diff --git a/types/imagemin/imagemin-tests.ts b/types/imagemin/imagemin-tests.ts new file mode 100644 index 0000000000..88a91980d6 --- /dev/null +++ b/types/imagemin/imagemin-tests.ts @@ -0,0 +1,9 @@ +import imagemin = require('imagemin'); + +imagemin(['*.png']).then((results: imagemin.Result[]) => { /* ... */ }); +imagemin(['*.png'], 'dist').then((results: imagemin.Result[]) => { /* ... */ }); +imagemin(['*.png'], { plugins: [] }).then((results: imagemin.Result[]) => { /* ... */ }); +imagemin(['*.png'], 'dist', { plugins: [] }).then((results: imagemin.Result[]) => { /* ... */ }); + +imagemin.buffer(Buffer.from([/* ... */])).then((result: Buffer) => { /* ... */ }); +imagemin.buffer(Buffer.from([/* ... */]), { plugins: [] }).then((result: Buffer) => { /* ... */ }); diff --git a/types/imagemin/index.d.ts b/types/imagemin/index.d.ts new file mode 100644 index 0000000000..c848818f31 --- /dev/null +++ b/types/imagemin/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for imagemin 6.0 +// Project: https://github.com/imagemin/imagemin#readme +// Definitions by: Romain Faust +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function imagemin(input: ReadonlyArray, outputOrOptions?: string | imagemin.Options): Promise; +declare function imagemin(input: ReadonlyArray, output?: string, options?: imagemin.Options): Promise; + +declare namespace imagemin { + type Plugin = (input: Buffer) => Promise; + + interface Options { + plugins: ReadonlyArray; + } + + interface Result { + data: Buffer; + path: string; + } + + function buffer(buffer: Buffer, options?: Options): Promise; +} + +export = imagemin; diff --git a/types/imagemin/tsconfig.json b/types/imagemin/tsconfig.json new file mode 100644 index 0000000000..849754b4d0 --- /dev/null +++ b/types/imagemin/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", + "imagemin-tests.ts" + ] +} diff --git a/types/imagemin/tslint.json b/types/imagemin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/imagemin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }