From 4c4087c6566becf9f7e8d9f38daafc0c07540ab8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 2 Oct 2015 17:03:29 -0700 Subject: [PATCH] Add compiler error for incompatible module formats --- Jakefile.js | 2 +- src/compiler/diagnosticMessages.json | 20 ++++++++++++-------- src/compiler/emitter.ts | 4 ++-- src/compiler/program.ts | 5 +++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 943f2eff5ec..84f2d527857 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -225,7 +225,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) { file(outFile, prereqs, function() { var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; - var options = "--module commonjs --noImplicitAny --noEmitOnError"; + var options = "--noImplicitAny --noEmitOnError"; // Keep comments when specifically requested // or when in debug mode. diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6986d7ff5fb..0685eb44304 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2262,14 +2262,6 @@ "code": 6063 }, - "Specify JSX code generation: 'preserve' or 'react'": { - "category": "Message", - "code": 6080 - }, - "Argument for '--jsx' must be 'preserve' or 'react'.": { - "category": "Message", - "code": 6081 - }, "Enables experimental support for ES7 decorators.": { "category": "Message", "code": 6065 @@ -2302,6 +2294,18 @@ "category": "Message", "code": 6072 }, + "Specify JSX code generation: 'preserve' or 'react'": { + "category": "Message", + "code": 6080 + }, + "Argument for '--jsx' must be 'preserve' or 'react'.": { + "category": "Message", + "code": 6081 + }, + "Only 'amd', 'umd', and 'system' modules are supported alongside --{0}.": { + "category": "Error", + "code": 6082 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 52b8760bbd1..7e4a1714d51 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -457,11 +457,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi }; let bundleEmitDelegates: Map<(node: SourceFile, startIndex: number, resolvePath?: boolean) => void> = { - [ModuleKind.ES6]: () => {}, + [ModuleKind.ES6]() { }, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, [ModuleKind.UMD]: emitUMDModule, - [ModuleKind.CommonJS]: () => {}, + [ModuleKind.CommonJS]() { }, }; if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f54906d85ee..163ddfa36c1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1063,6 +1063,11 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower)); } + // Cannot specify module gen that isn't amd, umd, or system with --out + if (outFile && options.module && options.module !== ModuleKind.AMD && options.module !== ModuleKind.UMD && options.module !== ModuleKind.System) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Only_amd_umd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); + } + if (options.noEmit) { if (options.out) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));