Remove the ModuleElement type in favor of Statement
This commit is contained in:
parent
01f2cce8cf
commit
32d57d900b
3 changed files with 15 additions and 17 deletions
|
@ -11323,7 +11323,7 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
function checkGrammarModuleElementContext(node: ModuleElement, errorMessage: DiagnosticMessage): boolean {
|
||||
function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
|
||||
if (node.parent.kind !== SyntaxKind.SourceFile && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.ModuleDeclaration) {
|
||||
grammarErrorOnFirstToken(node, errorMessage);
|
||||
return false;
|
||||
|
@ -11374,7 +11374,7 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
function getModuleStatements(node: Declaration): ModuleElement[] {
|
||||
function getModuleStatements(node: Declaration): Statement[] {
|
||||
if (node.kind === SyntaxKind.SourceFile) {
|
||||
return (<SourceFile>node).statements;
|
||||
}
|
||||
|
|
|
@ -4011,7 +4011,7 @@ module ts {
|
|||
return parseExpressionOrLabeledStatement();
|
||||
}
|
||||
|
||||
function parseDeclaration(): ModuleElement {
|
||||
function parseDeclaration(): Statement {
|
||||
let fullStart = getNodePos();
|
||||
let decorators = parseDecorators();
|
||||
let modifiers = parseModifiers();
|
||||
|
@ -4044,7 +4044,7 @@ module ts {
|
|||
if (decorators) {
|
||||
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
|
||||
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
|
||||
let node = <ModuleElement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
|
||||
let node = <Statement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
|
||||
node.pos = fullStart;
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
|
|
|
@ -808,7 +808,9 @@ module ts {
|
|||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface Statement extends Node, ModuleElement { }
|
||||
export interface Statement extends Node {
|
||||
_statementBrand: any;
|
||||
}
|
||||
|
||||
export interface Block extends Statement {
|
||||
statements: NodeArray<Statement>;
|
||||
|
@ -909,10 +911,6 @@ module ts {
|
|||
block: Block;
|
||||
}
|
||||
|
||||
export interface ModuleElement extends Node {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
|
||||
export interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
|
@ -960,16 +958,16 @@ module ts {
|
|||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
|
||||
export interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
export interface ModuleDeclaration extends Declaration, Statement {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
|
||||
export interface ModuleBlock extends Node, ModuleElement {
|
||||
statements: NodeArray<ModuleElement>
|
||||
export interface ModuleBlock extends Node, Statement {
|
||||
statements: NodeArray<Statement>
|
||||
}
|
||||
|
||||
export interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
||||
export interface ImportEqualsDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
|
||||
// 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external
|
||||
|
@ -985,7 +983,7 @@ module ts {
|
|||
// import "mod" => importClause = undefined, moduleSpecifier = "mod"
|
||||
// In rest of the cases, module specifier is string literal corresponding to module
|
||||
// ImportClause information is shown at its declaration below.
|
||||
export interface ImportDeclaration extends ModuleElement {
|
||||
export interface ImportDeclaration extends Statement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
|
@ -1005,7 +1003,7 @@ module ts {
|
|||
name: Identifier;
|
||||
}
|
||||
|
||||
export interface ExportDeclaration extends Declaration, ModuleElement {
|
||||
export interface ExportDeclaration extends Declaration, Statement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
|
@ -1025,7 +1023,7 @@ module ts {
|
|||
export type ImportSpecifier = ImportOrExportSpecifier;
|
||||
export type ExportSpecifier = ImportOrExportSpecifier;
|
||||
|
||||
export interface ExportAssignment extends Declaration, ModuleElement {
|
||||
export interface ExportAssignment extends Declaration, Statement {
|
||||
isExportEquals?: boolean;
|
||||
expression: Expression;
|
||||
}
|
||||
|
@ -1141,7 +1139,7 @@ module ts {
|
|||
|
||||
// Source files are declarations when they are external modules.
|
||||
export interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
statements: NodeArray<Statement>;
|
||||
endOfFileToken: Node;
|
||||
|
||||
fileName: string;
|
||||
|
|
Loading…
Reference in a new issue