From 3deeea18a5bbcad7facffc840d0d18b970b97ed6 Mon Sep 17 00:00:00 2001 From: Jeff Chan <695282+hkjeffchan@users.noreply.github.com> Date: Mon, 9 Sep 2019 08:12:51 +0800 Subject: [PATCH] type definitions for imagemin 7.0 (#38199) * Update definition to imagemin v7 * Update index.d.ts * update to fix test and lint * use buffer options * for not breaking other package test * fix related test so that destination is no longer optional * Revert "fix related test so that destination is no longer optional" This reverts commit 5ec10f750a3ed1f50a46d7cf67084586ee2def5a. --- types/imagemin/imagemin-tests.ts | 5 +---- types/imagemin/index.d.ts | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/types/imagemin/imagemin-tests.ts b/types/imagemin/imagemin-tests.ts index 88a91980d6..5c79b442cc 100644 --- a/types/imagemin/imagemin-tests.ts +++ b/types/imagemin/imagemin-tests.ts @@ -1,9 +1,6 @@ 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(['*.png'], { destination: '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 index c848818f31..ac73339a0a 100644 --- a/types/imagemin/index.d.ts +++ b/types/imagemin/index.d.ts @@ -1,26 +1,33 @@ -// Type definitions for imagemin 6.0 +// Type definitions for imagemin 7.0 // Project: https://github.com/imagemin/imagemin#readme // Definitions by: Romain Faust +// Jeff Chan // 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 function imagemin(input: ReadonlyArray, options?: imagemin.Options): Promise; declare namespace imagemin { type Plugin = (input: Buffer) => Promise; interface Options { + destination?: string; plugins: ReadonlyArray; + glob?: boolean; } interface Result { data: Buffer; - path: string; + sourcePath: string; + destinationPath: string; } - function buffer(buffer: Buffer, options?: Options): Promise; + interface BufferOptions { + plugins: ReadonlyArray; + } + + function buffer(buffer: Buffer, options?: BufferOptions): Promise; } export = imagemin;