[gulp-uglify] Update type definitions to v3.0 (#18514)

* [gulp-uglify] Update type definitions to v3.0.

* [gulp-uglify] Use existing declaration for `minify`.
This commit is contained in:
Leonard Thieu
2017-08-04 19:19:13 -04:00
committed by Sheetal Nandi
parent 257c478975
commit 879ee09301
5 changed files with 67 additions and 19 deletions

18
types/gulp-uglify/composer.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
import * as UglifyJS from 'uglify-js';
import * as GulpUglify from 'gulp-uglify';
interface Composer {
(uglify: Uglify, log: Logger): typeof GulpUglify;
}
interface Uglify {
minify: typeof UglifyJS.minify;
}
interface Logger {
warn: typeof console.warn;
}
declare const composer: Composer;
export = composer;

View File

@@ -1,17 +1,19 @@
import * as gulp from 'gulp';
import * as uglify from 'gulp-uglify';
import pump = require('pump');
import uglifyjs = require('uglify-js');
import composer = require('gulp-uglify/composer');
gulp.task('compress', function() {
var tsResult = gulp.src('lib/*.ts')
gulp.task('compress', () => {
const tsResult = gulp.src('lib/*.ts')
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('compress2', function() {
var tsResult = gulp.src('lib/*.ts')
gulp.task('compress2', () => {
const tsResult = gulp.src('lib/*.ts')
.pipe(uglify({
mangle: false,
preserveComments: "some",
compress: false,
output: {
max_line_len: 300
@@ -19,3 +21,34 @@ gulp.task('compress2', function() {
}))
.pipe(gulp.dest('dist'));
});
gulp.task('compress', (cb) => {
pump([
gulp.src('lib/*.js'),
uglify(),
gulp.dest('dist')
],
cb
);
});
const minify = composer(uglifyjs, console);
gulp.task('compress', (cb) => {
// the same options as described above
const options = {};
pump([
gulp.src('lib/*.js'),
minify(options),
gulp.dest('dist')
],
cb
);
});
gulp.task('compress', () => {
return gulp.src('lib/*.js')
.pipe(minify())
.pipe(gulp.dest('dist'));
});

View File

@@ -1,6 +1,7 @@
// Type definitions for gulp-uglify
// Type definitions for gulp-uglify 3.0
// Project: https://github.com/terinjokes/gulp-uglify
// Definitions by: Christopher Haws <https://github.com/ChristopherHaws/>
// Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
@@ -23,14 +24,6 @@ declare namespace GulpUglify {
* Pass an object to specify custom compressor options. Pass false to skip compression completely.
*/
compress?: UglifyJS.CompressorOptions | boolean;
/**
* A convenience option for options.output.comments. Defaults to preserving no comments.
* all - Preserve all comments in code blocks
* some - Preserve comments that start with a bang (!) or include a Closure Compiler directive (@preserve, @license, @cc_on)
* function - Specify your own comment preservation function. You will be passed the current node and the current comment and are expected to return either true or false.
*/
preserveComments?: string | ((node: any, comment: UglifyJS.Tokenizer) => boolean);
}
}

View File

@@ -6,20 +6,18 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"q": [ "q/v0" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"composer.d.ts",
"gulp-uglify-tests.ts"
]
}
}

View File

@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"callable-types": false
}
}