14
14
*/
15
15
// TypeScript Version: 2.3
16
16
17
- declare namespace Handlebars {
18
- export interface TemplateDelegate < T = any > {
17
+ declare global { // global for backwards compatibility
18
+
19
+ namespace Handlebars {
20
+ export interface TemplateDelegate < T = any > {
19
21
( context : T , options ?: RuntimeOptions ) : string ;
20
- }
22
+ }
21
23
22
- export type Template < T = any > = TemplateDelegate < T > | string ;
24
+ export type Template < T = any > = TemplateDelegate < T > | string ;
23
25
24
- export interface RuntimeOptions {
26
+ export interface RuntimeOptions {
25
27
partial ?: boolean ;
26
28
depths ?: any [ ] ;
27
29
helpers ?: { [ name : string ] : Function } ;
@@ -34,65 +36,65 @@ declare namespace Handlebars {
34
36
allowedProtoMethods ?: { [ name : string ] : boolean } ;
35
37
allowProtoPropertiesByDefault ?: boolean ;
36
38
allowProtoMethodsByDefault ?: boolean ;
37
- }
39
+ }
38
40
39
- export interface HelperOptions {
41
+ export interface HelperOptions {
40
42
fn : TemplateDelegate ;
41
43
inverse : TemplateDelegate ;
42
44
hash : Record < string , any > ;
43
45
data ?: any ;
44
- }
46
+ }
45
47
46
- export interface HelperDelegate {
48
+ export interface HelperDelegate {
47
49
( context ?: any , arg1 ?: any , arg2 ?: any , arg3 ?: any , arg4 ?: any , arg5 ?: any , options ?: HelperOptions ) : any ;
48
- }
49
- export interface HelperDeclareSpec {
50
+ }
51
+ export interface HelperDeclareSpec {
50
52
[ key : string ] : HelperDelegate ;
51
- }
53
+ }
52
54
53
- export interface ParseOptions {
55
+ export interface ParseOptions {
54
56
srcName ?: string ;
55
57
ignoreStandalone ?: boolean ;
56
- }
57
-
58
- export function registerHelper ( name : string , fn : HelperDelegate ) : void ;
59
- export function registerHelper ( name : HelperDeclareSpec ) : void ;
60
- export function unregisterHelper ( name : string ) : void ;
61
-
62
- export function registerPartial ( name : string , fn : Template ) : void ;
63
- export function registerPartial ( spec : { [ name : string ] : Template } ) : void ;
64
- export function unregisterPartial ( name : string ) : void ;
65
-
66
- // TODO: replace Function with actual signature
67
- export function registerDecorator ( name : string , fn : Function ) : void ;
68
- export function unregisterDecorator ( name : string ) : void ;
69
-
70
- export function K ( ) : void ;
71
- export function createFrame ( object : any ) : any ;
72
- export function blockParams ( obj : any [ ] , ids : any [ ] ) : any [ ] ;
73
- export function log ( level : number , obj : any ) : void ;
74
- export function parse ( input : string , options ?: ParseOptions ) : hbs . AST . Program ;
75
- export function parseWithoutProcessing ( input : string , options ?: ParseOptions ) : hbs . AST . Program ;
76
- export function compile < T = any > ( input : any , options ?: CompileOptions ) : HandlebarsTemplateDelegate < T > ;
77
- export function precompile ( input : any , options ?: PrecompileOptions ) : TemplateSpecification ;
78
- export function template < T = any > ( precompilation : TemplateSpecification ) : HandlebarsTemplateDelegate < T > ;
79
-
80
- export function create ( ) : typeof Handlebars ;
81
-
82
- export const escapeExpression : typeof Utils . escapeExpression ;
83
- //export const Utils: typeof hbs.Utils;
84
- export const logger : Logger ;
85
- export const templates : HandlebarsTemplates ;
86
- export const helpers : { [ name : string ] : HelperDelegate } ;
87
- export const partials : { [ name : string ] : any } ;
88
- // TODO: replace Function with actual signature
89
- export const decorators : { [ name : string ] : Function } ;
90
-
91
- export const VERSION : string ;
92
-
93
- export function noConflict ( ) : typeof Handlebars ;
94
-
95
- export class Exception {
58
+ }
59
+
60
+ export function registerHelper ( name : string , fn : HelperDelegate ) : void ;
61
+ export function registerHelper ( name : HelperDeclareSpec ) : void ;
62
+ export function unregisterHelper ( name : string ) : void ;
63
+
64
+ export function registerPartial ( name : string , fn : Template ) : void ;
65
+ export function registerPartial ( spec : { [ name : string ] : Template } ) : void ;
66
+ export function unregisterPartial ( name : string ) : void ;
67
+
68
+ // TODO: replace Function with actual signature
69
+ export function registerDecorator ( name : string , fn : Function ) : void ;
70
+ export function unregisterDecorator ( name : string ) : void ;
71
+
72
+ export function K ( ) : void ;
73
+ export function createFrame ( object : any ) : any ;
74
+ export function blockParams ( obj : any [ ] , ids : any [ ] ) : any [ ] ;
75
+ export function log ( level : number , obj : any ) : void ;
76
+ export function parse ( input : string , options ?: ParseOptions ) : hbs . AST . Program ;
77
+ export function parseWithoutProcessing ( input : string , options ?: ParseOptions ) : hbs . AST . Program ;
78
+ export function compile < T = any > ( input : any , options ?: CompileOptions ) : HandlebarsTemplateDelegate < T > ;
79
+ export function precompile ( input : any , options ?: PrecompileOptions ) : TemplateSpecification ;
80
+ export function template < T = any > ( precompilation : TemplateSpecification ) : HandlebarsTemplateDelegate < T > ;
81
+
82
+ export function create ( ) : typeof Handlebars ;
83
+
84
+ export const escapeExpression : typeof Utils . escapeExpression ;
85
+ //export const Utils: typeof hbs.Utils;
86
+ export const logger : Logger ;
87
+ export const templates : HandlebarsTemplates ;
88
+ export const helpers : { [ name : string ] : HelperDelegate } ;
89
+ export const partials : { [ name : string ] : any } ;
90
+ // TODO: replace Function with actual signature
91
+ export const decorators : { [ name : string ] : Function } ;
92
+
93
+ export const VERSION : string ;
94
+
95
+ export function noConflict ( ) : typeof Handlebars ;
96
+
97
+ export class Exception {
96
98
constructor ( message : string , node ?: hbs . AST . Node ) ;
97
99
description : string ;
98
100
fileName : string ;
@@ -104,15 +106,15 @@ declare namespace Handlebars {
104
106
stack ?: string ;
105
107
column ?: any ;
106
108
endColumn ?: any ;
107
- }
109
+ }
108
110
109
- export class SafeString {
111
+ export class SafeString {
110
112
constructor ( str : string ) ;
111
113
toString ( ) : string ;
112
114
toHTML ( ) : string ;
113
- }
115
+ }
114
116
115
- export namespace Utils {
117
+ export namespace Utils {
116
118
export function escapeExpression ( str : string ) : string ;
117
119
export function createFrame ( object : any ) : any ;
118
120
export function blockParams ( obj : any [ ] , ids : any [ ] ) : any [ ] ;
@@ -121,13 +123,13 @@ declare namespace Handlebars {
121
123
export function toString ( obj : any ) : string ;
122
124
export function isArray ( obj : any ) : boolean ;
123
125
export function isFunction ( obj : any ) : boolean ;
124
- }
126
+ }
125
127
126
- export namespace AST {
128
+ export namespace AST {
127
129
export const helpers : hbs . AST . helpers ;
128
- }
130
+ }
129
131
130
- interface ICompiler {
132
+ interface ICompiler {
131
133
accept ( node : hbs . AST . Node ) : void ;
132
134
Program ( program : hbs . AST . Program ) : void ;
133
135
BlockStatement ( block : hbs . AST . BlockStatement ) : void ;
@@ -146,9 +148,9 @@ declare namespace Handlebars {
146
148
UndefinedLiteral ( ) : void ;
147
149
NullLiteral ( ) : void ;
148
150
Hash ( hash : hbs . AST . Hash ) : void ;
149
- }
151
+ }
150
152
151
- export class Visitor implements ICompiler {
153
+ export class Visitor implements ICompiler {
152
154
accept ( node : hbs . AST . Node ) : void ;
153
155
acceptKey ( node : hbs . AST . Node , name : string ) : void ;
154
156
acceptArray ( arr : hbs . AST . Expression [ ] ) : void ;
@@ -169,103 +171,103 @@ declare namespace Handlebars {
169
171
UndefinedLiteral ( ) : void ;
170
172
NullLiteral ( ) : void ;
171
173
Hash ( hash : hbs . AST . Hash ) : void ;
172
- }
174
+ }
173
175
174
176
175
- export interface ResolvePartialOptions {
176
- name : string ;
177
- helpers ?: { [ name : string ] : Function } ;
178
- partials ?: { [ name : string ] : HandlebarsTemplateDelegate } ;
179
- decorators ?: { [ name : string ] : Function } ;
180
- data ?: any ;
177
+ export interface ResolvePartialOptions {
178
+ name : string ;
179
+ helpers ?: { [ name : string ] : Function } ;
180
+ partials ?: { [ name : string ] : HandlebarsTemplateDelegate } ;
181
+ decorators ?: { [ name : string ] : Function } ;
182
+ data ?: any ;
183
+ }
184
+
185
+ export namespace VM {
186
+ /**
187
+ * @deprecated
188
+ */
189
+ export function resolvePartial < T = any > ( partial : HandlebarsTemplateDelegate < T > | undefined , context : any , options : ResolvePartialOptions ) : HandlebarsTemplateDelegate < T > ;
190
+ }
181
191
}
182
192
183
- export namespace VM {
184
- /**
185
- * @deprecated
186
- */
187
- export function resolvePartial < T = any > ( partial : HandlebarsTemplateDelegate < T > | undefined , context : any , options : ResolvePartialOptions ) : HandlebarsTemplateDelegate < T > ;
193
+ /**
194
+ * Implement this interface on your MVW/MVVM/MVC views such as Backbone.View
195
+ **/
196
+ interface HandlebarsTemplatable {
197
+ template : HandlebarsTemplateDelegate ;
188
198
}
189
- }
190
-
191
- /**
192
- * Implement this interface on your MVW/MVVM/MVC views such as Backbone.View
193
- **/
194
- interface HandlebarsTemplatable {
195
- template : HandlebarsTemplateDelegate ;
196
- }
197
199
198
- // NOTE: for backward compatibility of this typing
199
- type HandlebarsTemplateDelegate < T = any > = Handlebars . TemplateDelegate < T > ;
200
+ // NOTE: for backward compatibility of this typing
201
+ type HandlebarsTemplateDelegate < T = any > = Handlebars . TemplateDelegate < T > ;
200
202
201
- interface HandlebarsTemplates {
202
- [ index : string ] : HandlebarsTemplateDelegate ;
203
- }
203
+ interface HandlebarsTemplates {
204
+ [ index : string ] : HandlebarsTemplateDelegate ;
205
+ }
204
206
205
- interface TemplateSpecification {
207
+ interface TemplateSpecification {
206
208
207
- }
209
+ }
208
210
209
- // for backward compatibility of this typing
210
- type RuntimeOptions = Handlebars . RuntimeOptions ;
211
-
212
- interface CompileOptions {
213
- data ?: boolean ;
214
- compat ?: boolean ;
215
- knownHelpers ?: KnownHelpers ;
216
- knownHelpersOnly ?: boolean ;
217
- noEscape ?: boolean ;
218
- strict ?: boolean ;
219
- assumeObjects ?: boolean ;
220
- preventIndent ?: boolean ;
221
- ignoreStandalone ?: boolean ;
222
- explicitPartialContext ?: boolean ;
223
- }
211
+ // for backward compatibility of this typing
212
+ type RuntimeOptions = Handlebars . RuntimeOptions ;
213
+
214
+ interface CompileOptions {
215
+ data ?: boolean ;
216
+ compat ?: boolean ;
217
+ knownHelpers ?: KnownHelpers ;
218
+ knownHelpersOnly ?: boolean ;
219
+ noEscape ?: boolean ;
220
+ strict ?: boolean ;
221
+ assumeObjects ?: boolean ;
222
+ preventIndent ?: boolean ;
223
+ ignoreStandalone ?: boolean ;
224
+ explicitPartialContext ?: boolean ;
225
+ }
224
226
225
- type KnownHelpers = {
226
- [ name in BuiltinHelperName | CustomHelperName ] : boolean ;
227
- } ;
228
-
229
- type BuiltinHelperName =
230
- "helperMissing" |
231
- "blockHelperMissing" |
232
- "each" |
233
- "if" |
234
- "unless" |
235
- "with" |
236
- "log" |
237
- "lookup" ;
238
-
239
- type CustomHelperName = string ;
240
-
241
- interface PrecompileOptions extends CompileOptions {
242
- srcName ?: string ;
243
- destName ?: string ;
244
- }
227
+ type KnownHelpers = {
228
+ [ name in BuiltinHelperName | CustomHelperName ] : boolean ;
229
+ } ;
230
+
231
+ type BuiltinHelperName =
232
+ "helperMissing" |
233
+ "blockHelperMissing" |
234
+ "each" |
235
+ "if" |
236
+ "unless" |
237
+ "with" |
238
+ "log" |
239
+ "lookup" ;
240
+
241
+ type CustomHelperName = string ;
242
+
243
+ interface PrecompileOptions extends CompileOptions {
244
+ srcName ?: string ;
245
+ destName ?: string ;
246
+ }
245
247
246
- declare namespace hbs {
247
- // for backward compatibility of this typing
248
- type SafeString = Handlebars . SafeString ;
248
+ namespace hbs {
249
+ // for backward compatibility of this typing
250
+ type SafeString = Handlebars . SafeString ;
249
251
250
- type Utils = typeof Handlebars . Utils ;
251
- }
252
+ type Utils = typeof Handlebars . Utils ;
253
+ }
252
254
253
- interface Logger {
254
- DEBUG : number ;
255
- INFO : number ;
256
- WARN : number ;
257
- ERROR : number ;
258
- level : number ;
255
+ interface Logger {
256
+ DEBUG : number ;
257
+ INFO : number ;
258
+ WARN : number ;
259
+ ERROR : number ;
260
+ level : number ;
259
261
260
- methodMap : { [ level : number ] : string } ;
262
+ methodMap : { [ level : number ] : string } ;
261
263
262
- log ( level : number , obj : string ) : void ;
263
- }
264
+ log ( level : number , obj : string ) : void ;
265
+ }
264
266
265
- type CompilerInfo = [ number /* revision */ , string /* versions */ ] ;
267
+ type CompilerInfo = [ number /* revision */ , string /* versions */ ] ;
266
268
267
- declare namespace hbs {
268
- namespace AST {
269
+ namespace hbs {
270
+ namespace AST {
269
271
interface Node {
270
272
type : string ;
271
273
loc : SourceLocation ;
@@ -410,13 +412,9 @@ declare namespace hbs {
410
412
scopeId ( path : PathExpression ) : boolean ;
411
413
simpleId ( path : PathExpression ) : boolean ;
412
414
}
415
+ }
413
416
}
414
- }
415
417
416
- declare module "handlebars" {
417
- export = Handlebars ;
418
418
}
419
419
420
- declare module "handlebars/runtime" {
421
- export = Handlebars ;
422
- }
420
+ export = Handlebars ;
0 commit comments