[estree] make function declaration id nullable (#24854)

* [estree] make function declaration id nullable

* apply review feedback

* [estree] make class declaration id nullable
This commit is contained in:
Stas Vilchik 2018-04-17 22:16:35 +02:00 committed by Ryan Cavanaugh
parent 5227ddf7d5
commit 8c3fdbcf02
2 changed files with 10 additions and 3 deletions

View File

@ -223,7 +223,8 @@ boolean = memberExpression.computed;
// Declarations
var functionDeclaration: ESTree.FunctionDeclaration;
identifier = functionDeclaration.id;
var identifierOrNull: ESTree.Identifier | null = functionDeclaration.id;
functionDeclaration.id = null;
var params: Array<ESTree.Pattern> = functionDeclaration.params;
blockStatement = functionDeclaration.body;
booleanMaybe = functionDeclaration.generator;
@ -237,6 +238,10 @@ var variableDeclarator: ESTree.VariableDeclarator;
pattern = variableDeclarator.id; // Pattern
expressionMaybe = variableDeclarator.init;
var classDeclaration: ESTree.ClassDeclaration;
identifierOrNull = classDeclaration.id;
classDeclaration.id = null;
// Clauses
// SwitchCase
string = switchCase.type;

View File

@ -196,7 +196,8 @@ interface BaseDeclaration extends BaseStatement { }
export interface FunctionDeclaration extends BaseFunction, BaseDeclaration {
type: "FunctionDeclaration";
id: Identifier;
/** It is null when a function declaration is a part of the `export default function` statement */
id: Identifier | null;
body: BlockStatement;
}
@ -473,7 +474,8 @@ export interface MethodDefinition extends BaseNode {
export interface ClassDeclaration extends BaseClass, BaseDeclaration {
type: "ClassDeclaration";
id: Identifier;
/** It is null when a class declaration is a part of the `export default class` statement */
id: Identifier | null;
}
export interface ClassExpression extends BaseClass, BaseExpression {