Skip to content

Commit 888750e

Browse files
committed
fix typings of resolvePartial-options
- derived from the object structure seen in the debugger closes #1534
1 parent 133b96a commit 888750e

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Gruntfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ module.exports = function(grunt) {
55
pkg: grunt.file.readJSON('package.json'),
66

77
eslint: {
8-
options: {
9-
},
108
files: [
119
'*.js',
1210
'bench/**/*.js',
1311
'tasks/**/*.js',
1412
'lib/**/!(*.min|parser).js',
1513
'spec/**/!(*.amd|json2|require).js',
16-
'integration-testing/**/*.js'
14+
'integration-testing/multi-nodejs-test/*.js',
15+
'integration-testing/webpack-test/*.js',
16+
'integration-testing/webpack-test/src/*.js'
1717
]
1818
},
1919

types/index.d.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* - Sergei Dorogin <https://github.com/evil-shrike>
99
* - webbiesdk <https://github.com/webbiesdk>
1010
* - Andrew Leedham <https://github.com/AndrewLeedham>
11+
* - Nils Knappmeier <https://github.com/nknapp>
1112
* For full history prior to their migration to handlebars.js, please see:
1213
* https://github.com/DefinitelyTyped/DefinitelyTyped/commits/1ce60bdc07f10e0b076778c6c953271c072bc894/types/handlebars/index.d.ts
1314
*/
@@ -21,7 +22,6 @@ declare namespace Handlebars {
2122
export type Template<T = any> = TemplateDelegate<T>|string;
2223

2324
export interface RuntimeOptions {
24-
name?: string;
2525
partial?: boolean;
2626
depths?: any[];
2727
helpers?: { [name: string]: Function };
@@ -150,11 +150,20 @@ declare namespace Handlebars {
150150
Hash(hash: hbs.AST.Hash): void;
151151
}
152152

153+
154+
export interface ResolvePartialOptions {
155+
name: string;
156+
helpers?: { [name: string]: Function };
157+
partials?: { [name: string]: HandlebarsTemplateDelegate };
158+
decorators?: { [name: string]: Function };
159+
data?: any;
160+
}
161+
153162
export namespace VM {
154163
/**
155164
* @deprecated
156165
*/
157-
export function resolvePartial<T = any>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: RuntimeOptions): HandlebarsTemplateDelegate<T>;
166+
export function resolvePartial<T = any>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: ResolvePartialOptions): HandlebarsTemplateDelegate<T>;
158167
}
159168
}
160169

types/test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ const parsedTmplWithoutOptions = Handlebars.parse('<p>Hello, my name is {{name}}
9292

9393
// Custom partial resolution.
9494
const originalResolvePartial = Handlebars.VM.resolvePartial;
95-
Handlebars.VM.resolvePartial = <T>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: RuntimeOptions): HandlebarsTemplateDelegate<T> => {
96-
const name = options.name;
95+
Handlebars.VM.resolvePartial = <T>(partial: HandlebarsTemplateDelegate<T> | undefined, context: any, options: Handlebars.ResolvePartialOptions): HandlebarsTemplateDelegate<T> => {
96+
const name = options.name.replace(/my/,'your');
9797
// transform name.
9898
options.name = name;
9999
return originalResolvePartial(partial, context, options);

0 commit comments

Comments
 (0)