Add gulp-image-resize types. (#24894)

This commit is contained in:
Aankhen
2018-04-12 00:12:15 +05:30
committed by Mohamed Hegazy
parent 2a5c6453e9
commit 53714e16a5
4 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import resize = require('gulp-image-resize');
resize(); // $ExpectType Transform
resize(undefined);
resize("1"); // $ExpectError
resize({ // $ExpectType Transform
width: 100,
height: 100,
crop: true,
upscale: false
});
resize({
widt: 5 // $ExpectError
});
resize({
width: undefined,
height: undefined,
upscale: undefined,
crop: undefined,
gravity: undefined,
quality: undefined,
format: undefined,
filter: undefined,
sharpen: undefined,
samplingFactor: undefined,
noProfile: undefined,
interlace: undefined,
imageMagick: undefined,
background: undefined,
flatten: undefined,
percentage: undefined,
cover: undefined
});
resize({ format: 'jpeg' });
resize({ width: 100 });
resize({ percentage: 50 });

38
types/gulp-image-resize/index.d.ts vendored Normal file
View File

@@ -0,0 +1,38 @@
// Type definitions for gulp-image-resize 0.13
// Project: https://github.com/scalableminds/gulp-image-resize
// Definitions by: Aankhen <https://github.com/Aankhen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="node" />
import * as stream from "stream";
import * as gm from "gm";
export = GulpImageResize;
declare function GulpImageResize(options?: GulpImageResize.Options): stream.Transform;
declare namespace GulpImageResize {
type SamplingFactor = [number, number];
interface Options {
width?: number;
height?: number;
upscale?: boolean;
crop?: boolean;
gravity?: gm.GravityDirection;
quality?: number;
format?: string;
filter?: gm.FilterType;
sharpen?: boolean | string;
samplingFactor?: SamplingFactor;
noProfile?: boolean;
interlace?: boolean;
imageMagick?: boolean;
background?: string;
flatten?: boolean;
percentage?: number;
cover?: boolean;
}
}

View File

@@ -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",
"gulp-image-resize-tests.ts"
]
}

View File

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