Mark some AST members as optional

This commit is contained in:
joeduffy 2017-01-16 10:00:40 -08:00
parent 1948380eb2
commit 96c7f4fa52
3 changed files with 16 additions and 15 deletions

View file

@ -18,20 +18,18 @@ export interface Definition extends Node {
// A module contains members, including variables, functions, and/or classes. // A module contains members, including variables, functions, and/or classes.
export interface Module extends Definition { export interface Module extends Definition {
kind: ModuleKind; kind: ModuleKind;
members: ModuleMembers; members?: ModuleMembers;
} }
export const moduleKind = "Module"; export const moduleKind = "Module";
export type ModuleKind = "Module"; export type ModuleKind = "Module";
export type Modules = { [token: string /*symbols.Token*/]: Definition }; export type Modules = { [token: string /*symbols.ModuleToken*/]: Module };
// A module member is a definition that belongs to a module. // A module member is a definition that belongs to a module.
export interface ModuleMember extends Definition { export interface ModuleMember extends Definition {
access?: symbols.Accessibility; access?: symbols.Accessibility;
} }
export type ModuleMembers = { [token: string /*symbols.ModuleToken*/]: ModuleMember }; export type ModuleMembers = { [token: string /*symbols.Token*/]: ModuleMember };
/* Classes */
// An export definition re-exports a definition from another module, possibly with a different name. // An export definition re-exports a definition from another module, possibly with a different name.
export interface Export extends ModuleMember { export interface Export extends ModuleMember {
@ -41,6 +39,8 @@ export interface Export extends ModuleMember {
export const exportKind = "Export"; export const exportKind = "Export";
export type ExportKind = "Export"; export type ExportKind = "Export";
/* Classes */
// A class can be constructed to create an object, and exports properties, methods, and has a number of attributes. // A class can be constructed to create an object, and exports properties, methods, and has a number of attributes.
export interface Class extends ModuleMember { export interface Class extends ModuleMember {
kind: ClassKind; kind: ClassKind;
@ -60,7 +60,7 @@ export interface ClassMember extends Definition {
access?: symbols.ClassMemberAccessibility; access?: symbols.ClassMemberAccessibility;
static?: boolean; static?: boolean;
} }
export type ClassMembers = { [token: string /*symbols.TypeToken*/]: ClassMember }; export type ClassMembers = { [token: string /*symbols.Token*/]: ClassMember };
/* Variables */ /* Variables */

View file

@ -47,8 +47,8 @@ export type StringLiteralKind = "StringLiteral";
// A array literal plus optional initialization. // A array literal plus optional initialization.
export interface ArrayLiteral extends Literal { export interface ArrayLiteral extends Literal {
kind: ArrayLiteralKind; kind: ArrayLiteralKind;
type: symbols.TypeToken; // the type of array to produce. type?: symbols.TypeToken; // the type of array to produce.
size?: Expression; // an optiojnal expression for the array size. size?: Expression; // an optional expression for the array size.
elements?: Expression[]; // an optional array of element expressions to store into the array. elements?: Expression[]; // an optional array of element expressions to store into the array.
} }
export const arrayLiteralKind = "ArrayLiteral"; export const arrayLiteralKind = "ArrayLiteral";
@ -57,7 +57,7 @@ export type ArrayLiteralKind = "ArrayLiteral";
// An object literal plus optional initialization. // An object literal plus optional initialization.
export interface ObjectLiteral extends Literal { export interface ObjectLiteral extends Literal {
kind: ObjectLiteralKind; kind: ObjectLiteralKind;
type: symbols.TypeToken; // the type of object to produce. type?: symbols.TypeToken; // the type of object to produce.
properties?: ObjectLiteralProperty[]; // an optional array of property initializers. properties?: ObjectLiteralProperty[]; // an optional array of property initializers.
} }
export const objectLiteralKind = "ObjectLiteral"; export const objectLiteralKind = "ObjectLiteral";
@ -137,7 +137,7 @@ export interface UnaryOperatorExpression extends Expression {
kind: UnaryOperatorExpressionKind; kind: UnaryOperatorExpressionKind;
operator: UnaryOperator; // the operator type. operator: UnaryOperator; // the operator type.
operand: Expression; // the right hand side operand. operand: Expression; // the right hand side operand.
postfix: boolean; // whether this is a postifx operator (only legal for UnaryPfixOperator). postfix?: boolean; // whether this is a postifx operator (only legal for UnaryPfixOperator).
} }
export const unaryOperatorExpressionKind = "UnaryOperatorExpression"; export const unaryOperatorExpressionKind = "UnaryOperatorExpression";
export type UnaryOperatorExpressionKind = "UnaryOperatorExpression"; export type UnaryOperatorExpressionKind = "UnaryOperatorExpression";

View file

@ -38,9 +38,9 @@ export const tryCatchFinallyKind = "TryCatchFinally";
export type TryCatchFinallyKind = "TryCatchFinally"; export type TryCatchFinallyKind = "TryCatchFinally";
export interface TryCatchBlock extends Node { export interface TryCatchBlock extends Node {
kind: TryCatchBlockKind; kind: TryCatchBlockKind;
exception: symbols.TypeToken; block: Block;
block: Block; exception?: symbols.TypeToken;
} }
export const tryCatchBlockKind = "TryCatchBlock"; export const tryCatchBlockKind = "TryCatchBlock";
export type TryCatchBlockKind = "TryCatchBlock"; export type TryCatchBlockKind = "TryCatchBlock";
@ -120,7 +120,8 @@ export type EmptyStatementKind = "EmptyStatement";
// Multiple statements in one (unlike a block, this doesn't introduce a new scope). // Multiple statements in one (unlike a block, this doesn't introduce a new scope).
export interface MultiStatement extends Statement { export interface MultiStatement extends Statement {
kind: MultiStatementKind; kind: MultiStatementKind;
statements: Statement[];
} }
export const multiStatementKind = "MultiStatement"; export const multiStatementKind = "MultiStatement";
export type MultiStatementKind = "MultiStatement"; export type MultiStatementKind = "MultiStatement";