From de10772b881f7c2339999915307f948e52075e82 Mon Sep 17 00:00:00 2001 From: Timothy Lindvall Date: Thu, 13 Dec 2018 14:55:03 -0800 Subject: [PATCH] Update typings for handlebars - Add optional options param to parse. This reflects the options param in the Handlebars source code. Also defines interface ParseOptions, which includes the options that have an effect on Handlebars parsing. - Fix duplicate properties in tsconfig.json. - Fix typo in import in handlebars-tests.ts. Reference Source: https://github.com/wycats/handlebars.js/blob/master/lib/handlebars/compiler/base.js#L11 Non-breaking change (new param is optional). --- types/handlebars/handlebars-tests.ts | 9 ++++++++- types/handlebars/index.d.ts | 7 ++++++- types/handlebars/tsconfig.json | 8 ++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/types/handlebars/handlebars-tests.ts b/types/handlebars/handlebars-tests.ts index 1ec2528db3..340bbde590 100644 --- a/types/handlebars/handlebars-tests.ts +++ b/types/handlebars/handlebars-tests.ts @@ -1,6 +1,6 @@ //import Handlebars = require('handlebars'); -import * as Handlerbars from 'handlebars'; +import * as Handlebars from 'handlebars'; const context = { author: { firstName: 'Alan', lastName: 'Johnson' }, @@ -78,3 +78,10 @@ template6([{url:"", title:""}]) const escapedExpression = Handlebars.Utils.escapeExpression(''); Handlebars.helpers !== undefined; + +const parsedTmpl = Handlebars.parse('

Hello, my name is {{name}}.

', { + srcName: "/foo/bar/baz.hbs", + ignoreStandalone: true +}); + +const parsedTmplWithoutOptions = Handlebars.parse('

Hello, my name is {{name}}.

'); diff --git a/types/handlebars/index.d.ts b/types/handlebars/index.d.ts index 6272dde3a0..d6bebcb457 100644 --- a/types/handlebars/index.d.ts +++ b/types/handlebars/index.d.ts @@ -35,6 +35,11 @@ declare namespace Handlebars { [key: string]: HelperDelegate; } + export interface ParseOptions { + srcName?: string, + ignoreStandalone?: boolean + } + export function registerHelper(name: string, fn: HelperDelegate): void; export function registerHelper(name: HelperDeclareSpec): void; export function unregisterHelper(name: string): void; @@ -52,7 +57,7 @@ declare namespace Handlebars { export function blockParams(obj: any[], ids: any[]): any[]; export function Exception(message: string): void; export function log(level: number, obj: any): void; - export function parse(input: string): hbs.AST.Program; + export function parse(input: string, options?: ParseOptions): hbs.AST.Program; export function compile(input: any, options?: CompileOptions): HandlebarsTemplateDelegate; export function precompile(input: any, options?: PrecompileOptions): TemplateSpecification; export function template(precompilation: TemplateSpecification): HandlebarsTemplateDelegate; diff --git a/types/handlebars/tsconfig.json b/types/handlebars/tsconfig.json index 5c7bf000d0..0008e2154e 100644 --- a/types/handlebars/tsconfig.json +++ b/types/handlebars/tsconfig.json @@ -19,9 +19,5 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "handlebars-tests.ts" - ] -} \ No newline at end of file + } +}