Added image-thumbnail types (#39086)

* Added image-thumbnail types

* Updated types to use the generator
This commit is contained in:
Noam Alffasy 2019-10-15 23:48:30 +03:00 committed by Andrew Branch
parent 83185eca3d
commit f7fb7dfada
4 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,14 @@
import { createReadStream } from 'fs';
import imageThumbnail = require('image-thumbnail');
imageThumbnail({ uri: '' }); // $ExpectType Promise<Buffer>
imageThumbnail({ uri: '' }, { responseType: 'base64' }); // $ExpectType Promise<string>
imageThumbnail(''); // $ExpectType Promise<Buffer>
imageThumbnail('', { responseType: 'base64' }); // $ExpectType Promise<string>
imageThumbnail(Buffer.from([])); // $ExpectType Promise<Buffer>
imageThumbnail(Buffer.from([]), { responseType: 'base64' }); // $ExpectType Promise<string>
imageThumbnail(createReadStream('')); // $ExpectType Promise<Buffer>
imageThumbnail(createReadStream(''), { responseType: 'base64' }); // $ExpectType Promise<string>

28
types/image-thumbnail/index.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
// Type definitions for image-thumbnail 1.0
// Project: https://github.com/onildoaguiar/image-thumbnail#readme
// Definitions by: Noam Alffasy <https://github.com/noamalffasy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { ReadStream } from 'fs';
export = imageFunction;
declare function imageFunction(
src: { uri: string } | string | Buffer | ReadStream,
options?: { responseType: 'buffer' } & imageFunction.Options,
): Promise<Buffer>;
declare function imageFunction(
src: { uri: string } | string | Buffer | ReadStream,
options?: { responseType: 'base64' } & imageFunction.Options,
): Promise<string>;
declare namespace imageFunction {
interface Options {
percentage?: number;
width?: number;
height?: number;
responseType?: string;
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"image-thumbnail-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }