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.
This commit is contained in:
Jeff Chan 2019-09-09 08:12:51 +08:00 committed by Mine Starks
parent 156a7ab7e1
commit 3deeea18a5
2 changed files with 13 additions and 9 deletions

View File

@ -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) => { /* ... */ });

View File

@ -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 <https://github.com/romain-faust>
// Jeff Chan <https://github.com/hkjeffchan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare function imagemin(input: ReadonlyArray<string>, outputOrOptions?: string | imagemin.Options): Promise<imagemin.Result[]>;
declare function imagemin(input: ReadonlyArray<string>, output?: string, options?: imagemin.Options): Promise<imagemin.Result[]>;
declare function imagemin(input: ReadonlyArray<string>, options?: imagemin.Options): Promise<imagemin.Result[]>;
declare namespace imagemin {
type Plugin = (input: Buffer) => Promise<Buffer>;
interface Options {
destination?: string;
plugins: ReadonlyArray<Plugin>;
glob?: boolean;
}
interface Result {
data: Buffer;
path: string;
sourcePath: string;
destinationPath: string;
}
function buffer(buffer: Buffer, options?: Options): Promise<Buffer>;
interface BufferOptions {
plugins: ReadonlyArray<Plugin>;
}
function buffer(buffer: Buffer, options?: BufferOptions): Promise<Buffer>;
}
export = imagemin;