Add gulp-svgmin types (#25599)

This commit is contained in:
Aankhen
2018-05-08 22:56:43 +05:30
committed by Sheetal Nandi
parent ba59e57720
commit 96e3ca2355
4 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import svgmin = require("gulp-svgmin");
import { basename, extname } from "path";
// From tests
svgmin({ plugins: [] });
svgmin({ plugins: [{ removeDoctype: false }] });
svgmin({ plugins: [{ removeDoctype: false }, { removeComments: false }] });
// From examples given in README
// $ExpectType Transform
svgmin();
// $ExpectType Transform
svgmin({
plugins: [{
removeDoctype: false
}, {
removeComments: false
}, {
cleanupNumericValues: {
floatPrecision: 2
}
}, {
convertColors: {
names2hex: false,
rgb2hex: false
}
}]
});
// $ExpectType Transform
svgmin({
js2svg: {
pretty: true
}
});
// $ExpectType Transform
svgmin(function getOptions(file) {
const prefix = basename(file.relative, extname(file.relative));
return {
plugins: [{
cleanupIDs: {
prefix: prefix + '-',
minify: true
}
}]
};
});

17
types/gulp-svgmin/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for gulp-svgmin 1.2
// Project: https://github.com/ben-eb/gulp-svgmin
// Definitions by: Aankhen <https://github.com/Aankhen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// (required because svgo specifies 2.2)
/// <reference types="node"/>
import SVGO = require("svgo");
import { Transform } from "stream";
import * as File from "vinyl";
export = GulpSvgmin;
declare function GulpSvgmin(cb: (file: File) => SVGO.Options): Transform;
declare function GulpSvgmin(options?: SVGO.Options): Transform;

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

View File

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