Skip to content

Commit 32d57d9

Browse files
committed
Remove the ModuleElement type in favor of Statement
1 parent 01f2cce commit 32d57d9

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11323,7 +11323,7 @@ module ts {
1132311323
}
1132411324
}
1132511325

11326-
function checkGrammarModuleElementContext(node: ModuleElement, errorMessage: DiagnosticMessage): boolean {
11326+
function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
1132711327
if (node.parent.kind !== SyntaxKind.SourceFile && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.ModuleDeclaration) {
1132811328
grammarErrorOnFirstToken(node, errorMessage);
1132911329
return false;
@@ -11374,7 +11374,7 @@ module ts {
1137411374
}
1137511375
}
1137611376

11377-
function getModuleStatements(node: Declaration): ModuleElement[] {
11377+
function getModuleStatements(node: Declaration): Statement[] {
1137811378
if (node.kind === SyntaxKind.SourceFile) {
1137911379
return (<SourceFile>node).statements;
1138011380
}

src/compiler/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,7 +4011,7 @@ module ts {
40114011
return parseExpressionOrLabeledStatement();
40124012
}
40134013

4014-
function parseDeclaration(): ModuleElement {
4014+
function parseDeclaration(): Statement {
40154015
let fullStart = getNodePos();
40164016
let decorators = parseDecorators();
40174017
let modifiers = parseModifiers();
@@ -4044,7 +4044,7 @@ module ts {
40444044
if (decorators) {
40454045
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
40464046
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
4047-
let node = <ModuleElement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
4047+
let node = <Statement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
40484048
node.pos = fullStart;
40494049
node.decorators = decorators;
40504050
setModifiers(node, modifiers);

src/compiler/types.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,9 @@ module ts {
808808
expression: UnaryExpression;
809809
}
810810

811-
export interface Statement extends Node, ModuleElement { }
811+
export interface Statement extends Node {
812+
_statementBrand: any;
813+
}
812814

813815
export interface Block extends Statement {
814816
statements: NodeArray<Statement>;
@@ -909,10 +911,6 @@ module ts {
909911
block: Block;
910912
}
911913

912-
export interface ModuleElement extends Node {
913-
_moduleElementBrand: any;
914-
}
915-
916914
export interface ClassLikeDeclaration extends Declaration {
917915
name?: Identifier;
918916
typeParameters?: NodeArray<TypeParameterDeclaration>;
@@ -960,16 +958,16 @@ module ts {
960958
members: NodeArray<EnumMember>;
961959
}
962960

963-
export interface ModuleDeclaration extends Declaration, ModuleElement {
961+
export interface ModuleDeclaration extends Declaration, Statement {
964962
name: Identifier | LiteralExpression;
965963
body: ModuleBlock | ModuleDeclaration;
966964
}
967965

968-
export interface ModuleBlock extends Node, ModuleElement {
969-
statements: NodeArray<ModuleElement>
966+
export interface ModuleBlock extends Node, Statement {
967+
statements: NodeArray<Statement>
970968
}
971969

972-
export interface ImportEqualsDeclaration extends Declaration, ModuleElement {
970+
export interface ImportEqualsDeclaration extends Declaration, Statement {
973971
name: Identifier;
974972

975973
// 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external
@@ -985,7 +983,7 @@ module ts {
985983
// import "mod" => importClause = undefined, moduleSpecifier = "mod"
986984
// In rest of the cases, module specifier is string literal corresponding to module
987985
// ImportClause information is shown at its declaration below.
988-
export interface ImportDeclaration extends ModuleElement {
986+
export interface ImportDeclaration extends Statement {
989987
importClause?: ImportClause;
990988
moduleSpecifier: Expression;
991989
}
@@ -1005,7 +1003,7 @@ module ts {
10051003
name: Identifier;
10061004
}
10071005

1008-
export interface ExportDeclaration extends Declaration, ModuleElement {
1006+
export interface ExportDeclaration extends Declaration, Statement {
10091007
exportClause?: NamedExports;
10101008
moduleSpecifier?: Expression;
10111009
}
@@ -1025,7 +1023,7 @@ module ts {
10251023
export type ImportSpecifier = ImportOrExportSpecifier;
10261024
export type ExportSpecifier = ImportOrExportSpecifier;
10271025

1028-
export interface ExportAssignment extends Declaration, ModuleElement {
1026+
export interface ExportAssignment extends Declaration, Statement {
10291027
isExportEquals?: boolean;
10301028
expression: Expression;
10311029
}
@@ -1141,7 +1139,7 @@ module ts {
11411139

11421140
// Source files are declarations when they are external modules.
11431141
export interface SourceFile extends Declaration {
1144-
statements: NodeArray<ModuleElement>;
1142+
statements: NodeArray<Statement>;
11451143
endOfFileToken: Node;
11461144

11471145
fileName: string;

0 commit comments

Comments
 (0)