fix the type of google-closure-compiler CompileOptions (#9228)

The type shown in the JSDoc is wrong.  This patch copies the sample
code from the README into the test to verify that the type is right.
This commit is contained in:
Evan Martin
2016-05-06 07:44:19 -06:00
committed by Alex Eagle
parent 02ba1e3e95
commit ea5859b23c
2 changed files with 15 additions and 1 deletions
@@ -26,3 +26,12 @@ let jsonStream: GoogleClosureCompiler.JSONStreamFile[] = [
src: 'var x = "hello, world";',
},
];
// Test the various options formats -- see
// https://github.com/ChadKillingsworth/closure-compiler-npm#specifying-options
let optionsFormats: GoogleClosureCompiler.CompileOptions = {
js: ['/file-one.js', '/file-two.js'],
compilation_level: 'ADVANCED',
js_output_file: 'out.js',
debug: true
};
+6 -1
View File
@@ -5,6 +5,10 @@
/// <reference path="../node/node.d.ts" />
// Note: the types seen in the JSDoc are wrong:
// https://github.com/ChadKillingsworth/closure-compiler-npm/issues/21
// Be careful to read the code when choosing types.
declare module 'google-closure-compiler' {
import * as child_process from 'child_process';
@@ -26,7 +30,8 @@ declare module 'google-closure-compiler' {
getFullCommand(): string;
}
type CompileOptions = {[key: string]: string};
type CompileOption = string | boolean;
type CompileOptions = string[] | {[key: string]: (CompileOption|CompileOption[])};
var compiler: {
new (opts: (CompileOptions|string[]),
extraCommandArgs?: string[]): Compiler;