Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[estree] Use null for optional fields in estree #15052

Merged
merged 2 commits into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/acorn/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ declare namespace acorn {
class SourceLocation implements ESTree.SourceLocation {
start: Position;
end: Position;
source?: string;
source?: string | null;

constructor(p: Parser, start: Position, end: Position);
}
Expand Down
14 changes: 7 additions & 7 deletions types/estree/estree-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ expression = expressionStatement.expression;
var ifStatement: ESTree.IfStatement;
expression = ifStatement.test;
statement = ifStatement.consequent;
var statementOrNull: ESTree.Statement | undefined = ifStatement.alternate;
var statementOrNull: ESTree.Statement | null | undefined = ifStatement.alternate;

// LabeledStatement
var labeledStatement: ESTree.LabeledStatement;
Expand All @@ -141,18 +141,18 @@ switchCase = switchStatement.cases[0];

// ReturnStatement
var returnStatement: ESTree.ReturnStatement;
var expressionMaybe: ESTree.Expression | undefined = returnStatement.argument;
var expressionMaybe: ESTree.Expression | null | undefined = returnStatement.argument;

// TryStatement
var tryStatement: ESTree.TryStatement;
blockStatement = tryStatement.block;
var catchClauseMaybe: ESTree.CatchClause | undefined = tryStatement.handler;
var blockStatementMaybe: ESTree.BlockStatement | undefined = tryStatement.finalizer;
var catchClauseMaybe: ESTree.CatchClause | null | undefined = tryStatement.handler;
var blockStatementMaybe: ESTree.BlockStatement | null | undefined = tryStatement.finalizer;

// ForStatement
var forStatement: ESTree.ForStatement;
var variableDeclaratorOrExpressionMaybe: typeof variableDeclaratorOrExpression | undefined = forStatement.init;
var expressionMaybe: ESTree.Expression | undefined = forStatement.update;
var variableDeclaratorOrExpressionMaybe: typeof variableDeclaratorOrExpression | null | undefined = forStatement.init;
var expressionMaybe: ESTree.Expression | null | undefined = forStatement.update;

// ForInStatement
var forInStatement: ESTree.ForInStatement;
Expand All @@ -176,7 +176,7 @@ string = property.kind;

// FunctionExpression
var functionExpression: ESTree.FunctionExpression;
var identifierMaybe: ESTree.Identifier | undefined = functionExpression.id;
var identifierMaybe: ESTree.Identifier | null | undefined = functionExpression.id;
pattern = functionExpression.params[0];
pattern = assignmentPattern.left;
expression = assignmentPattern.right;
Expand Down
20 changes: 10 additions & 10 deletions types/estree/flow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ declare namespace ESTree {

interface ClassImplements extends Node {
id: Identifier;
typeParameters?: TypeParameterInstantiation;
typeParameters?: TypeParameterInstantiation | null;
}

interface ClassProperty {
key: Expression;
value?: Expression;
typeAnnotation?: TypeAnnotation;
value?: Expression | null;
typeAnnotation?: TypeAnnotation | null;
computed: boolean;
static: boolean;
}

interface DeclareClass extends FlowDeclaration {
id: Identifier;
typeParameters?: TypeParameterDeclaration;
typeParameters?: TypeParameterDeclaration | null;
body: ObjectTypeAnnotation;
extends: Array<InterfaceExtends>;
}
Expand All @@ -60,8 +60,8 @@ declare namespace ESTree {
interface FunctionTypeAnnotation extends FlowTypeAnnotation {
params: Array<FunctionTypeParam>;
returnType: FlowTypeAnnotation;
rest?: FunctionTypeParam;
typeParameters?: TypeParameterDeclaration;
rest?: FunctionTypeParam | null;
typeParameters?: TypeParameterDeclaration | null;
}

interface FunctionTypeParam {
Expand All @@ -72,17 +72,17 @@ declare namespace ESTree {

interface GenericTypeAnnotation extends FlowTypeAnnotation {
id: Identifier | QualifiedTypeIdentifier;
typeParameters?: TypeParameterInstantiation;
typeParameters?: TypeParameterInstantiation | null;
}

interface InterfaceExtends extends Node {
id: Identifier | QualifiedTypeIdentifier;
typeParameters?: TypeParameterInstantiation;
typeParameters?: TypeParameterInstantiation | null;
}

interface InterfaceDeclaration extends FlowDeclaration {
id: Identifier;
typeParameters?: TypeParameterDeclaration;
typeParameters?: TypeParameterDeclaration | null;
extends: Array<InterfaceExtends>;
body: ObjectTypeAnnotation;
}
Expand Down Expand Up @@ -115,7 +115,7 @@ declare namespace ESTree {

interface TypeAlias extends FlowDeclaration {
id: Identifier;
typeParameters?: TypeParameterDeclaration;
typeParameters?: TypeParameterDeclaration | null;
right: FlowTypeAnnotation;
}

Expand Down
38 changes: 19 additions & 19 deletions types/estree/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface BaseNode {

leadingComments?: Array<Comment>;
trailingComments?: Array<Comment>;
loc?: SourceLocation;
loc?: SourceLocation | null;
range?: [number, number];
}
export type Node =
Expand All @@ -42,7 +42,7 @@ export interface Comment {
}

interface SourceLocation {
source?: string;
source?: string | null;
start: Position;
end: Position;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ export interface IfStatement extends BaseStatement {
type: "IfStatement";
test: Expression;
consequent: Statement;
alternate?: Statement;
alternate?: Statement | null;
}

export interface LabeledStatement extends BaseStatement {
Expand All @@ -111,12 +111,12 @@ export interface LabeledStatement extends BaseStatement {

export interface BreakStatement extends BaseStatement {
type: "BreakStatement";
label?: Identifier;
label?: Identifier | null;
}

export interface ContinueStatement extends BaseStatement {
type: "ContinueStatement";
label?: Identifier;
label?: Identifier | null;
}

export interface WithStatement extends BaseStatement {
Expand All @@ -133,7 +133,7 @@ export interface SwitchStatement extends BaseStatement {

export interface ReturnStatement extends BaseStatement {
type: "ReturnStatement";
argument?: Expression;
argument?: Expression | null;
}

export interface ThrowStatement extends BaseStatement {
Expand All @@ -144,8 +144,8 @@ export interface ThrowStatement extends BaseStatement {
export interface TryStatement extends BaseStatement {
type: "TryStatement";
block: BlockStatement;
handler?: CatchClause;
finalizer?: BlockStatement;
handler?: CatchClause | null;
finalizer?: BlockStatement | null;
}

export interface WhileStatement extends BaseStatement {
Expand All @@ -162,9 +162,9 @@ export interface DoWhileStatement extends BaseStatement {

export interface ForStatement extends BaseStatement {
type: "ForStatement";
init?: VariableDeclaration | Expression;
test?: Expression;
update?: Expression;
init?: VariableDeclaration | Expression | null;
test?: Expression | null;
update?: Expression | null;
body: Statement;
}

Expand Down Expand Up @@ -201,7 +201,7 @@ export interface VariableDeclaration extends BaseDeclaration {
export interface VariableDeclarator extends BaseNode {
type: "VariableDeclarator";
id: Pattern;
init?: Expression;
init?: Expression | null;
}

type Expression =
Expand Down Expand Up @@ -239,7 +239,7 @@ export interface Property extends BaseNode {
}

export interface FunctionExpression extends BaseFunction, BaseExpression {
id?: Identifier;
id?: Identifier | null;
type: "FunctionExpression";
body: BlockStatement;
}
Expand Down Expand Up @@ -319,7 +319,7 @@ interface BasePattern extends BaseNode { }

export interface SwitchCase extends BaseNode {
type: "SwitchCase";
test?: Expression;
test?: Expression | null;
consequent: Array<Statement>;
}

Expand Down Expand Up @@ -389,7 +389,7 @@ export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {

export interface YieldExpression extends BaseExpression {
type: "YieldExpression";
argument?: Expression;
argument?: Expression | null;
delegate: boolean;
}

Expand Down Expand Up @@ -443,7 +443,7 @@ export interface AssignmentPattern extends BasePattern {

export type Class = ClassDeclaration | ClassExpression;
interface BaseClass extends BaseNode {
superClass?: Expression;
superClass?: Expression | null;
body: ClassBody;
}

Expand All @@ -468,7 +468,7 @@ export interface ClassDeclaration extends BaseClass, BaseDeclaration {

export interface ClassExpression extends BaseClass, BaseExpression {
type: "ClassExpression";
id?: Identifier;
id?: Identifier | null;
}

export interface MetaProperty extends BaseExpression {
Expand Down Expand Up @@ -510,9 +510,9 @@ export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {

export interface ExportNamedDeclaration extends BaseModuleDeclaration {
type: "ExportNamedDeclaration";
declaration?: Declaration;
declaration?: Declaration | null;
specifiers: Array<ExportSpecifier>;
source?: Literal;
source?: Literal | null;
}

export interface ExportSpecifier extends BaseModuleSpecifier {
Expand Down