Remove flag and compare position

This commit is contained in:
Yui T
2015-01-29 16:07:55 -08:00
parent e4b206c4a2
commit fd20695957
3 changed files with 10 additions and 14 deletions

View File

@@ -3292,16 +3292,17 @@ module ts {
function emitSignatureParametersForArrow(node: FunctionLikeDeclaration) {
// Check whether the parameter list needs parentheses and preserve no-parenthesis
if (node.flags & NodeFlags.SimpleArrowFunction) {
increaseIndent();
var parameters = node.parameters;
var omitCount = hasRestParameters(node) ? 1 : 0;
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
decreaseIndent();
}
else {
emitSignatureParameters(node);
if (node.parameters.length === 1){
if (node.pos === node.parameters[0].pos) {
increaseIndent();
var parameters = node.parameters;
var omitCount = hasRestParameters(node) ? 1 : 0;
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
decreaseIndent();
return;
}
}
emitSignatureParameters(node);
}
function emitSignatureAndBody(node: FunctionLikeDeclaration) {

View File

@@ -2883,9 +2883,6 @@ module ts {
node.parameters = <NodeArray<ParameterDeclaration>>[parameter];
node.parameters.pos = parameter.pos;
node.parameters.end = parameter.end;
// Add node flags for simple arrow function(no parenthesis around parameters)
// so that in emit state we can check this flag and preserve users original text
node.flags |= NodeFlags.SimpleArrowFunction;
parseExpected(SyntaxKind.EqualsGreaterThanToken);
node.body = parseArrowFunctionExpressionBody();

View File

@@ -293,8 +293,6 @@ module ts {
Const = 0x00001000, // Variable declaration
OctalLiteral = 0x00002000,
SimpleArrowFunction = 0x00004000, // Arrow function without parenthesized parameters
Modifier = Export | Ambient | Public | Private | Protected | Static,
AccessibilityModifier = Public | Private | Protected,
BlockScoped = Let | Const