Add AST type definitions to handlebars.d.ts

Also put a module around the "SafeString" type to fix the compiler error.
This commit is contained in:
gscshoyru
2014-10-08 13:34:18 -04:00
parent 2147e98170
commit adf02b7701
+116 -5
View File
@@ -26,14 +26,14 @@ interface HandlebarsCommon {
createFrame(object: any): any;
Exception(message: string): void;
SafeString: typeof SafeString;
SafeString: typeof hbs.SafeString;
logger: Logger;
log(level: number, obj: any): void;
}
interface HandlebarsStatic extends HandlebarsCommon {
parse(input: string): boolean;
parse(input: string): hbs.AST.ProgramNode;
compile(input: any, options?: any): HandlebarsTemplateDelegate;
}
@@ -46,9 +46,11 @@ interface HandlebarsRuntimeStatic extends HandlebarsCommon {
templates: HandlebarsTemplates;
}
declare class SafeString {
constructor(str: string);
static toString(): string;
declare module hbs {
class SafeString {
constructor(str: string);
static toString(): string;
}
}
interface Logger {
@@ -63,6 +65,115 @@ interface Logger {
log(level: number, obj: string): void;
}
declare module hbs {
module AST {
interface IStripInfo {
left?: boolean;
right?: boolean;
inlineStandalone?: boolean;
}
class NodeBase {
firstColumn: number;
firstLine: number;
lastColumn: number;
lastLine: number;
type: string;
}
class ProgramNode extends NodeBase {
statements: NodeBase[];
}
class IdNode extends NodeBase {
original: string;
parts: string[];
string: string;
depth: number;
idName: string;
isSimple: boolean;
stringModeValue: string;
}
class HashNode extends NodeBase {
pairs: {0: string;
1: NodeBase}[];
}
class SexprNode extends NodeBase {
hash: HashNode;
id: NodeBase;
params: NodeBase[];
isHelper: boolean;
eligibleHelper: boolean;
}
class MustacheNode extends NodeBase {
strip: IStripInfo;
escaped: boolean;
sexpr: SexprNode;
}
class BlockNode extends NodeBase {
mustache: MustacheNode;
program: ProgramNode;
inverse: ProgramNode;
strip: IStripInfo;
isInverse: boolean;
}
class PartialNameNode extends NodeBase {
name: string;
}
class PartialNode extends NodeBase {
partialName: PartialNameNode;
context: NodeBase;
hash: HashNode;
strip: IStripInfo;
}
class RawBlockNode extends NodeBase {
mustache: MustacheNode;
program: ProgramNode;
}
class ContentNode extends NodeBase {
original: string;
string: string;
}
class DataNode extends NodeBase {
id: IdNode;
stringModeValue: string;
idName: string;
}
class StringNode extends NodeBase {
original: string;
string: string;
stringModeValue: string;
}
class NumberNode extends NodeBase {
original: string;
number: string;
stringModeValue: number;
}
class BooleanNode extends NodeBase {
bool: string;
stringModeValue: boolean;
}
class CommentNode extends NodeBase {
comment: string;
strip: IStripInfo;
}
}
}
declare module "handlebars" {
export = Handlebars;
}