8000 PR Feedback · nycdotnet/TypeScript@0f16e68 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f16e68

Browse files
committed
PR Feedback
1 parent ab811f9 commit 0f16e68

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/compiler/factory.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ namespace ts {
180180
block.statements = createNodeArray(statements);
181181
return block;
182182
}
183+
183184
export function createVariableDeclaration(name: BindingPattern | Identifier, initializer?: Expression, location?: TextRange): VariableDeclaration {
184185
const node = <VariableDeclaration>createNode(SyntaxKind.VariableDeclaration, location);
185186
node.name = name;
@@ -203,17 +204,17 @@ namespace ts {
203204
export function createLiteral(value: string): StringLiteral;
204205
export function createLiteral(value: number): LiteralExpression;
205206
export function createLiteral(value: string | number | boolean): PrimaryExpression;
206-
export function createLiteral<T extends PrimaryExpression>(value: string | number | boolean): T {
207+
export function createLiteral(value: string | number | boolean): PrimaryExpression {
207208
if (typeof value === "number") {
208-
const node = <T & LiteralExpression>createNode(SyntaxKind.NumericLiteral);
209+
const node = <LiteralExpression>createNode(SyntaxKind.NumericLiteral);
209210
node.text = value.toString();
210211
return node;
211212
}
212213
else if (typeof value === "boolean") {
213-
return <T>createNode(value ? SyntaxKind.TrueKeyword : SyntaxKind.FalseKeyword);
214+
return <PrimaryExpression>createNode(value ? SyntaxKind.TrueKeyword : SyntaxKind.FalseKeyword);
214215
}
215216
else {
216-
const node = <T & StringLiteral>createNode(SyntaxKind.StringLiteral);
217+
const node = <StringLiteral>createNode(SyntaxKind.StringLiteral);
217218
node.text = String(value);
218219
return node;
219220
}

src/compiler/transformer.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,25 +223,28 @@ namespace ts {
223223
}
224224

225225
/**
226-
* Records a hoisted variable declaration within a lexical environment.
226+
* Records a hoisted variable declaration for the provided name within a lexical environment.
227227
*/
228228
function hoistVariableDeclaration(name: Identifier): void {
229+
const decl = createVariableDeclaration(name);
229230
if (!hoistedVariableDeclarations) {
230-
hoistedVariableDeclarations = [];
231+
hoistedVariableDeclarations = [decl];
232+
}
233+
else {
234+
hoistedVariableDeclarations.push(decl);
231235
}
232-
233-
hoistedVariableDeclarations.push(createVariableDeclaration(name));
234236
}
235237

236238
/**
237239
* Records a hoisted function declaration within a lexical environment.
238240
*/
239241
function hoistFunctionDeclaration(func: FunctionDeclaration): void {
240242
if (!hoistedFunctionDeclarations) {
241-
hoistedFunctionDeclarations = [];
243+
hoistedFunctionDeclarations = [func];
244+
}
245+
else {
246+
hoistedFunctionDeclarations.push(func);
242247
}
243-
244-
hoistedFunctionDeclarations.push(func);
245248
}
246249

247250
/**

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,7 @@ namespace ts {
27952795
EmitSuperHelper = 1 << 2, // Emit the basic _super helper for async methods.
27962796
EmitAdvancedSuperHelper = 1 << 3, // Emit the advanced _super helper for async methods.
27972797
UMDDefine = 1 << 4, // This node should be replaced with the UMD define helper.
2798-
NoLexicalEnvironment = 1 << 5, // A new LexicalEnvironment should *not* be introduced when emitting this node.
2798+
NoLexicalEnvironment = 1 << 5, // A new LexicalEnvironment should *not* be introduced when emitting this node, this is primarily used when printing a SystemJS module.
27992799
SingleLine = 1 << 6, // The contents of this node should be emit on a single line.
28002800
MultiLine = 1 << 7, // The contents of this node should be emit on multiple lines.
28012801
AdviseOnEmitNode = 1 << 8, // The node printer should invoke the onBeforeEmitNode and onAfterEmitNode callbacks when printing this node.

0 commit comments

Comments
 (0)
0