PR Feedback
This commit is contained in:
parent
ab811f90d0
commit
0f16e68335
3 changed files with 16 additions and 12 deletions
|
@ -180,6 +180,7 @@ namespace ts {
|
|||
block.statements = createNodeArray(statements);
|
||||
return block;
|
||||
}
|
||||
|
||||
export function createVariableDeclaration(name: BindingPattern | Identifier, initializer?: Expression, location?: TextRange): VariableDeclaration {
|
||||
const node = <VariableDeclaration>createNode(SyntaxKind.VariableDeclaration, location);
|
||||
node.name = name;
|
||||
|
@ -203,17 +204,17 @@ namespace ts {
|
|||
export function createLiteral(value: string): StringLiteral;
|
||||
export function createLiteral(value: number): LiteralExpression;
|
||||
export function createLiteral(value: string | number | boolean): PrimaryExpression;
|
||||
export function createLiteral<T extends PrimaryExpression>(value: string | number | boolean): T {
|
||||
export function createLiteral(value: string | number | boolean): PrimaryExpression {
|
||||
if (typeof value === "number") {
|
||||
const node = <T & LiteralExpression>createNode(SyntaxKind.NumericLiteral);
|
||||
const node = <LiteralExpression>createNode(SyntaxKind.NumericLiteral);
|
||||
node.text = value.toString();
|
||||
return node;
|
||||
}
|
||||
else if (typeof value === "boolean") {
|
||||
return <T>createNode(value ? SyntaxKind.TrueKeyword : SyntaxKind.FalseKeyword);
|
||||
return <PrimaryExpression>createNode(value ? SyntaxKind.TrueKeyword : SyntaxKind.FalseKeyword);
|
||||
}
|
||||
else {
|
||||
const node = <T & StringLiteral>createNode(SyntaxKind.StringLiteral);
|
||||
const node = <StringLiteral>createNode(SyntaxKind.StringLiteral);
|
||||
node.text = String(value);
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -223,14 +223,16 @@ namespace ts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Records a hoisted variable declaration within a lexical environment.
|
||||
* Records a hoisted variable declaration for the provided name within a lexical environment.
|
||||
*/
|
||||
function hoistVariableDeclaration(name: Identifier): void {
|
||||
const decl = createVariableDeclaration(name);
|
||||
if (!hoistedVariableDeclarations) {
|
||||
hoistedVariableDeclarations = [];
|
||||
hoistedVariableDeclarations = [decl];
|
||||
}
|
||||
else {
|
||||
hoistedVariableDeclarations.push(decl);
|
||||
}
|
||||
|
||||
hoistedVariableDeclarations.push(createVariableDeclaration(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,11 +240,12 @@ namespace ts {
|
|||
*/
|
||||
function hoistFunctionDeclaration(func: FunctionDeclaration): void {
|
||||
if (!hoistedFunctionDeclarations) {
|
||||
hoistedFunctionDeclarations = [];
|
||||
hoistedFunctionDeclarations = [func];
|
||||
}
|
||||
|
||||
else {
|
||||
hoistedFunctionDeclarations.push(func);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new lexical environment. Any existing hoisted variable or function declarations
|
||||
|
|
|
@ -2795,7 +2795,7 @@ namespace ts {
|
|||
EmitSuperHelper = 1 << 2, // Emit the basic _super helper for async methods.
|
||||
EmitAdvancedSuperHelper = 1 << 3, // Emit the advanced _super helper for async methods.
|
||||
UMDDefine = 1 << 4, // This node should be replaced with the UMD define helper.
|
||||
NoLexicalEnvironment = 1 << 5, // A new LexicalEnvironment should *not* be introduced when emitting this node.
|
||||
NoLexicalEnvironment = 1 << 5, // A new LexicalEnvironment should *not* be introduced when emitting this node, this is primarily used when printing a SystemJS module.
|
||||
SingleLine = 1 << 6, // The contents of this node should be emit on a single line.
|
||||
MultiLine = 1 << 7, // The contents of this node should be emit on multiple lines.
|
||||
AdviseOnEmitNode = 1 << 8, // The node printer should invoke the onBeforeEmitNode and onAfterEmitNode callbacks when printing this node.
|
||||
|
|
Loading…
Reference in a new issue