From f7fb7dfada0161ce73bef8b5986dc11e543e37b7 Mon Sep 17 00:00:00 2001 From: Noam Alffasy Date: Tue, 15 Oct 2019 23:48:30 +0300 Subject: [PATCH] Added image-thumbnail types (#39086) * Added image-thumbnail types * Updated types to use the generator --- .../image-thumbnail/image-thumbnail-tests.ts | 14 ++++++++++ types/image-thumbnail/index.d.ts | 28 +++++++++++++++++++ types/image-thumbnail/tsconfig.json | 23 +++++++++++++++ types/image-thumbnail/tslint.json | 1 + 4 files changed, 66 insertions(+) create mode 100644 types/image-thumbnail/image-thumbnail-tests.ts create mode 100644 types/image-thumbnail/index.d.ts create mode 100644 types/image-thumbnail/tsconfig.json create mode 100644 types/image-thumbnail/tslint.json diff --git a/types/image-thumbnail/image-thumbnail-tests.ts b/types/image-thumbnail/image-thumbnail-tests.ts new file mode 100644 index 0000000000..282b1097de --- /dev/null +++ b/types/image-thumbnail/image-thumbnail-tests.ts @@ -0,0 +1,14 @@ +import { createReadStream } from 'fs'; +import imageThumbnail = require('image-thumbnail'); + +imageThumbnail({ uri: '' }); // $ExpectType Promise +imageThumbnail({ uri: '' }, { responseType: 'base64' }); // $ExpectType Promise + +imageThumbnail(''); // $ExpectType Promise +imageThumbnail('', { responseType: 'base64' }); // $ExpectType Promise + +imageThumbnail(Buffer.from([])); // $ExpectType Promise +imageThumbnail(Buffer.from([]), { responseType: 'base64' }); // $ExpectType Promise + +imageThumbnail(createReadStream('')); // $ExpectType Promise +imageThumbnail(createReadStream(''), { responseType: 'base64' }); // $ExpectType Promise diff --git a/types/image-thumbnail/index.d.ts b/types/image-thumbnail/index.d.ts new file mode 100644 index 0000000000..01bd40d6e9 --- /dev/null +++ b/types/image-thumbnail/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for image-thumbnail 1.0 +// Project: https://github.com/onildoaguiar/image-thumbnail#readme +// Definitions by: Noam Alffasy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { ReadStream } from 'fs'; + +export = imageFunction; + +declare function imageFunction( + src: { uri: string } | string | Buffer | ReadStream, + options?: { responseType: 'buffer' } & imageFunction.Options, +): Promise; +declare function imageFunction( + src: { uri: string } | string | Buffer | ReadStream, + options?: { responseType: 'base64' } & imageFunction.Options, +): Promise; + +declare namespace imageFunction { + interface Options { + percentage?: number; + width?: number; + height?: number; + responseType?: string; + } +} diff --git a/types/image-thumbnail/tsconfig.json b/types/image-thumbnail/tsconfig.json new file mode 100644 index 0000000000..23296b2f04 --- /dev/null +++ b/types/image-thumbnail/tsconfig.json @@ -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" + ] +} diff --git a/types/image-thumbnail/tslint.json b/types/image-thumbnail/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/image-thumbnail/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }