diff --git a/types/estree/estree-tests.ts b/types/estree/estree-tests.ts index 5cd065d03f..24e92ddc38 100644 --- a/types/estree/estree-tests.ts +++ b/types/estree/estree-tests.ts @@ -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 = 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; diff --git a/types/estree/index.d.ts b/types/estree/index.d.ts index 068cbfd8ce..0133991c9f 100644 --- a/types/estree/index.d.ts +++ b/types/estree/index.d.ts @@ -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 {