From c4091e488889ecd59e09c520c07c4d87752182cf Mon Sep 17 00:00:00 2001 From: Diogo Franco Date: Tue, 4 Jul 2017 11:28:17 +0900 Subject: [PATCH] Improve type of HandlebarsTemplateDelegate Adds an optional type argument that should be useful for .hbs.d.ts files. The RuntimeOptions were specified by looking at https://github.com/wycats/handlebars.js/blob/680ec96/lib/handlebars/runtime.js#L131-L171 -- these don't seem to be documented anywhere. --- types/handlebars/index.d.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/types/handlebars/index.d.ts b/types/handlebars/index.d.ts index 71cc0a2cfe..7572d19824 100644 --- a/types/handlebars/index.d.ts +++ b/types/handlebars/index.d.ts @@ -96,8 +96,8 @@ interface HandlebarsTemplatable { template: HandlebarsTemplateDelegate; } -interface HandlebarsTemplateDelegate { - (context: any, options?: any): string; +interface HandlebarsTemplateDelegate { + (context: T, options?: RuntimeOptions): string; } interface HandlebarsTemplates { @@ -108,6 +108,14 @@ interface TemplateSpecification { } +interface RuntimeOptions { + partial?: boolean; + depths?: any[]; + helpers?: { [name: string]: Function } + partials?: { [name: string]: HandlebarsTemplateDelegate } + decorators?: { [name: string]: Function } +} + interface CompileOptions { data?: boolean; compat?: boolean;