From 3f5582eaa09280993a3ee1b31a087975e2973b76 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sun, 25 Oct 2015 00:21:09 +0500 Subject: [PATCH] lodash: signatures of the method _.template changed --- lodash/lodash-tests.ts | 50 +++++++++++++++++++++++++++--------------- lodash/lodash.d.ts | 20 +++++++++++++++-- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index c083edd4c..53e8dc28f 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3611,24 +3611,38 @@ result = _('abc').startsWith('a'); result = _('abc').startsWith('a', 1); // _.template -interface TestTemplateOptions { - escape?: RegExp; - evaluate?: RegExp; - imports?: _.Dictionary; - interpolate?: RegExp; - variable?: string; -} -interface TestTemplateExecutor { - (obj?: Object): string; - source: string; -} -{ - let testTemplateOptions: TestTemplateOptions - let result: TestTemplateExecutor; - result = _.template(''); - result = _.template('', testTemplateOptions); - result = _('').template(); - result = _('').template(testTemplateOptions); + +module TestTemplate { + interface TemplateExecutor { + (obj?: Object): string; + source: string; + } + + let options: { + escape?: RegExp; + evaluate?: RegExp; + imports?: _.Dictionary; + interpolate?: RegExp; + sourceURL?: string; + variable?: string; + }; + + { + let result: TemplateExecutor; + + result = _.template(''); + result = _.template('', options); + + result = _('').template(); + result = _('').template(options); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _('').chain().template(); + result = _('').chain().template(options); + } } // _.trim diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 881124328..0307a8535 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9231,6 +9231,13 @@ declare module _ { } //_.template + interface TemplateOptions extends TemplateSettings { + /** + * The sourceURL of the template's compiled source. + */ + sourceURL?: string; + } + interface TemplateExecutor { (data?: Object): string; source: string; @@ -9259,19 +9266,28 @@ declare module _ { * @param options.evaluate The "evaluate" delimiter. * @param options.imports An object to import into the template as free variables. * @param options.interpolate The "interpolate" delimiter. + * @param options.sourceURL The sourceURL of the template's compiled source. * @param options.variable The data object variable name. * @return Returns the compiled template function. */ template( string: string, - options?: TemplateSettings): TemplateExecutor; + options?: TemplateOptions + ): TemplateExecutor; } interface LoDashImplicitWrapper { /** * @see _.template */ - template(options?: TemplateSettings): TemplateExecutor; + template(options?: TemplateOptions): TemplateExecutor; + } + + interface LoDashExplicitWrapper { + /** + * @see _.template + */ + template(options?: TemplateOptions): LoDashExplicitObjectWrapper; } //_.trim