From 837a8935c77ed60226192fbc48796d1840fa0d25 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 18 Jul 2014 14:06:08 -0700 Subject: [PATCH] Remove error about missing module flag from checker --- src/compiler/checker.ts | 26 -------------------------- src/compiler/commandLineParser.ts | 3 ++- src/harness/harness.ts | 3 ++- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 52eeb1d6c1c..bacfc99085f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -54,7 +54,6 @@ module ts { var stringLiteralTypes: Map = {}; var emitExtends = false; - var modulesVerified = false; var mergedSymbols: Symbol[] = []; var symbolLinks: SymbolLinks[] = []; @@ -4509,7 +4508,6 @@ module ts { function checkConstructorDeclaration(node: ConstructorDeclaration) { // TODO - checkDeclarationModifiers(node); checkSignatureDeclaration(node); checkSourceElement(node.body); @@ -4682,12 +4680,6 @@ module ts { return false; } - function checkDeclarationModifiers(node: Node) { - if (node.flags & NodeFlags.Export && node.parent.kind === SyntaxKind.SourceFile) { - checkModulesEnabled(node); - } - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode: SignatureDeclaration): void { var signature = getSignatureFromDeclaration(signatureDeclarationNode); if (!signature.hasStringLiterals) { @@ -4850,7 +4842,6 @@ module ts { } function checkFunctionDeclaration(node: FunctionDeclaration) { - checkDeclarationModifiers(node); checkSignatureDeclaration(node); var symbol = getSymbolOfNode(node); @@ -5082,7 +5073,6 @@ module ts { } function checkVariableStatement(node: VariableStatement) { - checkDeclarationModifiers(node); forEach(node.declarations, checkVariableDeclaration); } @@ -5337,7 +5327,6 @@ module ts { } function checkClassDeclaration(node: ClassDeclaration) { - checkDeclarationModifiers(node); checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); checkTypeParameters(node.typeParameters); checkCollisionWithCapturedThisVariable(node, node.name); @@ -5493,7 +5482,6 @@ module ts { } function checkInterfaceDeclaration(node: InterfaceDeclaration) { - checkDeclarationModifiers(node); checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0); checkTypeParameters(node.typeParameters); var symbol = getSymbolOfNode(node); @@ -5539,7 +5527,6 @@ module ts { } function checkEnumDeclaration(node: EnumDeclaration) { - checkDeclarationModifiers(node); checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); var enumSymbol = getSymbolOfNode(node); @@ -5612,7 +5599,6 @@ module ts { } function checkModuleDeclaration(node: ModuleDeclaration) { - checkDeclarationModifiers(node); checkCollisionWithCapturedThisVariable(node, node.name); var symbol = getSymbolOfNode(node); if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node)) { @@ -5638,7 +5624,6 @@ module ts { } function checkImportDeclaration(node: ImportDeclaration) { - checkDeclarationModifiers(node); checkCollisionWithCapturedThisVariable(node, node.name); var symbol = getSymbolOfNode(node); var target: Symbol; @@ -5660,7 +5645,6 @@ module ts { // Import declaration for an external module if (node.parent.kind === SyntaxKind.SourceFile) { // Parent is a source file, check that external modules are enabled - checkModulesEnabled(node); target = resolveImport(symbol); } else if (node.parent.kind === SyntaxKind.ModuleBlock && (node.parent.parent).name.kind === SyntaxKind.StringLiteral) { @@ -5691,20 +5675,10 @@ module ts { } } } - - function checkModulesEnabled(node: Node) { - if (!modulesVerified) { - if (!program.getCompilerOptions().module) { - error(node, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided); - } - modulesVerified = true; - } - } function checkExportAssignment(node: ExportAssignment) { var container = node.parent; if (container.kind === SyntaxKind.SourceFile) { - checkModulesEnabled(node); } else { // In a module, the immediate parent will be a block, so climb up one more parent diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 05acd4e17b1..8abd3c00d9e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -45,7 +45,8 @@ module ts { export function parseCommandLine(commandLine: string[]): ParsedCommandLine { // Set default compiler option values var options: CompilerOptions = { - target: ScriptTarget.ES3 + target: ScriptTarget.ES3, + module: ModuleKind.None }; var filenames: string[] = []; var errors: Diagnostic[] = []; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c35ba97df3a..6060f31ce3f 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -618,6 +618,7 @@ module Harness { options = options || { noResolve: false }; options.target = options.target || ts.ScriptTarget.ES3; + options.module = options.module || ts.ModuleKind.None; if (settingsCallback) { settingsCallback(null); @@ -717,7 +718,7 @@ module Harness { var filemap: { [name: string]: ts.SourceFile; } = {}; var register = (file: { unitName: string; content: string; }) => { var filename = Path.switchToForwardSlashes(file.unitName); - filemap[filename] = ts.createSourceFile(filename, file.content, options.target || ts.ScriptTarget.ES3); + filemap[filename] = ts.createSourceFile(filename, file.content, options.target); }; inputFiles.forEach(register); otherFiles.forEach(register);