added missing type fields in typings and tests for them
This commit is contained in:
committed by
Nils Knappmeier
parent
b793350fec
commit
0440af2147
Vendored
+19
-2
@@ -270,6 +270,7 @@ declare namespace hbs {
|
||||
interface Statement extends Node {}
|
||||
|
||||
interface MustacheStatement extends Statement {
|
||||
type: 'MustacheStatement';
|
||||
path: PathExpression | Literal;
|
||||
params: Expression[];
|
||||
hash: Hash;
|
||||
@@ -280,6 +281,7 @@ declare namespace hbs {
|
||||
interface Decorator extends MustacheStatement { }
|
||||
|
||||
interface BlockStatement extends Statement {
|
||||
type: 'BlockStatement';
|
||||
path: PathExpression;
|
||||
params: Expression[];
|
||||
hash: Hash;
|
||||
@@ -293,6 +295,7 @@ declare namespace hbs {
|
||||
interface DecoratorBlock extends BlockStatement { }
|
||||
|
||||
interface PartialStatement extends Statement {
|
||||
type: 'PartialStatement';
|
||||
name: PathExpression | SubExpression;
|
||||
params: Expression[];
|
||||
hash: Hash;
|
||||
@@ -301,6 +304,7 @@ declare namespace hbs {
|
||||
}
|
||||
|
||||
interface PartialBlockStatement extends Statement {
|
||||
type: 'PartialBlockStatement';
|
||||
name: PathExpression | SubExpression;
|
||||
params: Expression[];
|
||||
hash: Hash;
|
||||
@@ -310,11 +314,13 @@ declare namespace hbs {
|
||||
}
|
||||
|
||||
interface ContentStatement extends Statement {
|
||||
type: 'ContentStatement';
|
||||
value: string;
|
||||
original: StripFlags;
|
||||
}
|
||||
|
||||
interface CommentStatement extends Statement {
|
||||
type: 'CommentStatement';
|
||||
value: string;
|
||||
strip: StripFlags;
|
||||
}
|
||||
@@ -322,12 +328,14 @@ declare namespace hbs {
|
||||
interface Expression extends Node {}
|
||||
|
||||
interface SubExpression extends Expression {
|
||||
type: 'SubExpression';
|
||||
path: PathExpression;
|
||||
params: Expression[];
|
||||
hash: Hash;
|
||||
}
|
||||
|
||||
interface PathExpression extends Expression {
|
||||
type: 'PathExpression';
|
||||
data: boolean;
|
||||
depth: number;
|
||||
parts: string[];
|
||||
@@ -336,29 +344,38 @@ declare namespace hbs {
|
||||
|
||||
interface Literal extends Expression {}
|
||||
interface StringLiteral extends Literal {
|
||||
type: 'StringLiteral';
|
||||
value: string;
|
||||
original: string;
|
||||
}
|
||||
|
||||
interface BooleanLiteral extends Literal {
|
||||
type: 'BooleanLiteral';
|
||||
value: boolean;
|
||||
original: boolean;
|
||||
}
|
||||
|
||||
interface NumberLiteral extends Literal {
|
||||
type: 'NumberLiteral';
|
||||
value: number;
|
||||
original: number;
|
||||
}
|
||||
|
||||
interface UndefinedLiteral extends Literal {}
|
||||
interface UndefinedLiteral extends Literal {
|
||||
type: 'UndefinedLiteral';
|
||||
}
|
||||
|
||||
interface NullLiteral extends Literal {}
|
||||
interface NullLiteral extends Literal {
|
||||
type: 'NullLiteral';
|
||||
}
|
||||
|
||||
interface Hash extends Node {
|
||||
type: 'Hash';
|
||||
pairs: HashPair[];
|
||||
}
|
||||
|
||||
interface HashPair extends Node {
|
||||
type: 'HashPair';
|
||||
key: string;
|
||||
value: Expression;
|
||||
}
|
||||
|
||||
+83
-1
@@ -110,4 +110,86 @@ Handlebars.compile('test', {
|
||||
|
||||
Handlebars.compile('test')({},{allowCallsToHelperMissing: true});
|
||||
|
||||
Handlebars.compile('test')({},{});
|
||||
Handlebars.compile('test')({},{});
|
||||
|
||||
|
||||
const allthings = {} as hbs.AST.MustacheStatement |
|
||||
hbs.AST.BlockStatement |
|
||||
hbs.AST.PartialStatement |
|
||||
hbs.AST.PartialBlockStatement |
|
||||
hbs.AST.ContentStatement |
|
||||
hbs.AST.CommentStatement |
|
||||
hbs.AST.SubExpression |
|
||||
hbs.AST.PathExpression |
|
||||
hbs.AST.StringLiteral |
|
||||
hbs.AST.BooleanLiteral |
|
||||
hbs.AST.NumberLiteral |
|
||||
hbs.AST.UndefinedLiteral |
|
||||
hbs.AST.NullLiteral |
|
||||
hbs.AST.Hash |
|
||||
hbs.AST.HashPair;
|
||||
|
||||
switch(allthings.type) {
|
||||
case "MustacheStatement":
|
||||
let mustacheStatement: hbs.AST.MustacheStatement;
|
||||
mustacheStatement = allthings;
|
||||
break;
|
||||
case "BlockStatement":
|
||||
let blockStatement: hbs.AST.BlockStatement;
|
||||
blockStatement = allthings;
|
||||
break;
|
||||
case "PartialStatement":
|
||||
let partialStatement: hbs.AST.PartialStatement;
|
||||
partialStatement = allthings;
|
||||
break;
|
||||
case "PartialBlockStatement":
|
||||
let partialBlockStatement: hbs.AST.PartialBlockStatement;
|
||||
partialBlockStatement = allthings;
|
||||
break;
|
||||
case "ContentStatement":
|
||||
let ContentStatement: hbs.AST.ContentStatement;
|
||||
ContentStatement = allthings;
|
||||
break;
|
||||
case "CommentStatement":
|
||||
let CommentStatement: hbs.AST.CommentStatement;
|
||||
CommentStatement = allthings;
|
||||
break;
|
||||
case "SubExpression":
|
||||
let SubExpression: hbs.AST.SubExpression;
|
||||
SubExpression = allthings;
|
||||
break;
|
||||
case "PathExpression":
|
||||
let PathExpression: hbs.AST.PathExpression;
|
||||
PathExpression = allthings;
|
||||
break;
|
||||
case "StringLiteral":
|
||||
let StringLiteral: hbs.AST.StringLiteral;
|
||||
StringLiteral = allthings;
|
||||
break;
|
||||
case "BooleanLiteral":
|
||||
let BooleanLiteral: hbs.AST.BooleanLiteral;
|
||||
BooleanLiteral = allthings;
|
||||
break;
|
||||
case "NumberLiteral":
|
||||
let NumberLiteral: hbs.AST.NumberLiteral;
|
||||
NumberLiteral = allthings;
|
||||
break;
|
||||
case "UndefinedLiteral":
|
||||
let UndefinedLiteral: hbs.AST.UndefinedLiteral;
|
||||
UndefinedLiteral = allthings;
|
||||
break;
|
||||
case "NullLiteral":
|
||||
let NullLiteral: hbs.AST.NullLiteral;
|
||||
NullLiteral = allthings;
|
||||
break;
|
||||
case "Hash":
|
||||
let Hash: hbs.AST.Hash;
|
||||
Hash = allthings;
|
||||
break;
|
||||
case "HashPair":
|
||||
let HashPair: hbs.AST.HashPair;
|
||||
HashPair = allthings;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Reference in New Issue
Block a user