From ea5859b23c4c533a8cf228cc8ae577cab264493c Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Fri, 6 May 2016 06:44:19 -0700 Subject: [PATCH] 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. --- google-closure-compiler/google-closure-compiler-tests.ts | 9 +++++++++ google-closure-compiler/google-closure-compiler.d.ts | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/google-closure-compiler/google-closure-compiler-tests.ts b/google-closure-compiler/google-closure-compiler-tests.ts index b87bb4948c..b558ee9516 100644 --- a/google-closure-compiler/google-closure-compiler-tests.ts +++ b/google-closure-compiler/google-closure-compiler-tests.ts @@ -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 +}; diff --git a/google-closure-compiler/google-closure-compiler.d.ts b/google-closure-compiler/google-closure-compiler.d.ts index e1a21ab106..acfcc7cccb 100644 --- a/google-closure-compiler/google-closure-compiler.d.ts +++ b/google-closure-compiler/google-closure-compiler.d.ts @@ -5,6 +5,10 @@ /// +// 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;