diff --git a/types/handlebars/handlebars-tests.ts b/types/handlebars/handlebars-tests.ts
index 71215b5294..95342c2e63 100644
--- a/types/handlebars/handlebars-tests.ts
+++ b/types/handlebars/handlebars-tests.ts
@@ -36,7 +36,7 @@ var post = { url: '/hello-world', body: 'Hello World!' };
var context2 = { posts: [post] };
var source2 = '
{{#posts}}- {{{link_to this}}}
{{/posts}}
';
-var template2 = Handlebars.compile(source2);
+var template2: HandlebarsTemplateDelegate<{ posts: { url: string, body: string }[] }> = Handlebars.compile(source2);
template2(context2);
Handlebars.registerHelper('link_to', (title: string, context: typeof post) => {
@@ -45,14 +45,14 @@ Handlebars.registerHelper('link_to', (title: string, context: typeof post) => {
var context3 = { posts: [{url: '/hello-world', body: 'Hello World!'}] };
var source3 = '{{#posts}}- {{{link_to "Post" this}}}
{{/posts}}
';
-var template3 = Handlebars.compile(source3);
+var template3 = Handlebars.compile(source3);
template3(context3);
var source4 = '{{#people}}- {{#link}}{{name}}{{/link}}
{{/people}}
';
Handlebars.registerHelper('link', function(context: any) {
return '' + context.fn(this) + '';
});
-var template4 = Handlebars.compile(source4);
+var template4 = Handlebars.compile<{ people: { name: string, id: number }[] }>(source4);
var data2 = { 'people': [
{ 'name': 'Alan', 'id': 1 },
{ 'name': 'Yehuda', 'id': 2 }
diff --git a/types/handlebars/index.d.ts b/types/handlebars/index.d.ts
index 71cc0a2cfe..56c341aa47 100644
--- a/types/handlebars/index.d.ts
+++ b/types/handlebars/index.d.ts
@@ -2,7 +2,7 @@
// Project: http://handlebarsjs.com/
// Definitions by: Boris Yankov
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-
+// TypeScript Version: 2.3
declare namespace Handlebars {
export function registerHelper(name: string, fn: Function, inverse?: boolean): void;
@@ -19,9 +19,9 @@ declare namespace Handlebars {
export function Exception(message: string): void;
export function log(level: number, obj: any): void;
export function parse(input: string): hbs.AST.Program;
- export function compile(input: any, options?: CompileOptions): HandlebarsTemplateDelegate;
+ export function compile(input: any, options?: CompileOptions): HandlebarsTemplateDelegate;
export function precompile(input: any, options?: PrecompileOptions): TemplateSpecification;
- export function template(precompilation: TemplateSpecification): HandlebarsTemplateDelegate;
+ export function template(precompilation: TemplateSpecification): HandlebarsTemplateDelegate;
export function create(): typeof Handlebars;
@@ -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;
diff --git a/types/koa-hbs/index.d.ts b/types/koa-hbs/index.d.ts
index 481738efc3..cace80c852 100644
--- a/types/koa-hbs/index.d.ts
+++ b/types/koa-hbs/index.d.ts
@@ -2,6 +2,7 @@
// Project: https://github.com/gilt/koa-hbs
// Definitions by: Jacob Malone , Mudkip
// Definitions: https://github.com/jcbmln/DefinitelyTyped
+// TypeScript Version: 2.3
/* =================== USAGE ===================
@@ -57,4 +58,4 @@ declare module "koa" {
export interface Context {
render(tpl: string, locals?: {[key: string]: any}): Promise;
}
-}
\ No newline at end of file
+}
diff --git a/types/swag/index.d.ts b/types/swag/index.d.ts
index 29ba129fe5..cd7bb6ccaa 100644
--- a/types/swag/index.d.ts
+++ b/types/swag/index.d.ts
@@ -2,6 +2,7 @@
// Project: https://github.com/elving/swag
// Definitions by: Shogo Iwano
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.3
///