From 32d57d900bf60593c2bf4cf187c24d3d5cc15060 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 10 Jun 2015 11:26:51 -0700 Subject: [PATCH] Remove the ModuleElement type in favor of Statement --- src/compiler/checker.ts | 4 ++-- src/compiler/parser.ts | 4 ++-- src/compiler/types.ts | 24 +++++++++++------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9ae346ec717..1d17075df71 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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 (node).statements; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 79ee3f6da68..44b623a8af9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -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 = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); + let node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index de9fe811081..70962ea13c8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -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; @@ -909,10 +911,6 @@ module ts { block: Block; } - export interface ModuleElement extends Node { - _moduleElementBrand: any; - } - export interface ClassLikeDeclaration extends Declaration { name?: Identifier; typeParameters?: NodeArray; @@ -960,16 +958,16 @@ module ts { members: NodeArray; } - 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 + export interface ModuleBlock extends Node, Statement { + statements: NodeArray } - 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; + statements: NodeArray; endOfFileToken: Node; fileName: string;