From e4f57569b721662841d6599474adcc6cc375e396 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 28 Oct 2014 19:45:18 +0100 Subject: [PATCH] addressed feedback --- src/compiler/checker.ts | 10 ++++++++-- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/emitter.ts | 6 +++--- src/compiler/tsc.ts | 2 +- src/compiler/types.ts | 4 ++-- src/harness/harness.ts | 6 ++---- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7a959c0dbfc..91b27812d04 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -109,7 +109,7 @@ module ts { getAliasedSymbol: resolveImport, isUndefinedSymbol: symbol => symbol === undefinedSymbol, isArgumentsSymbol: symbol => symbol === argumentsSymbol, - hasEarlyErrors: hasEarlyErrors + isEmitBlocked: isEmitBlocked }; var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined"); @@ -8316,6 +8316,12 @@ module ts { return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0; } + function isEmitBlocked(sourceFile?: SourceFile): boolean { + return program.getDiagnostics(sourceFile).length !== 0 || + hasEarlyErrors(sourceFile) || + (compilerOptions.noEmitOnError && getDiagnostics(sourceFile).length !== 0); + } + function hasEarlyErrors(sourceFile?: SourceFile): boolean { return forEach(getDiagnostics(sourceFile), d => d.isEarly); } @@ -8403,7 +8409,7 @@ module ts { getEnumMemberValue: getEnumMemberValue, isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName, hasSemanticErrors: hasSemanticErrors, - hasEarlyErrors: hasEarlyErrors, + isEmitBlocked: isEmitBlocked, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, writeTypeAtLocation: writeTypeAtLocation, diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index ad6452d1639..71d68c546d2 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -57,7 +57,7 @@ module ts { { name: "noEmitOnError", type: "boolean", - description: Diagnostics.Do_not_emit_JavaScript_on_error, + description: Diagnostics.Do_not_emit_outputs_if_any_type_checking_errors_were_reported, }, { name: "noImplicitAny", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 3e464e62c33..61842486450 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -364,7 +364,7 @@ module ts { Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." }, Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, - Do_not_emit_JavaScript_on_error: { code: 6007, category: DiagnosticCategory.Message, key: "Do not emit JavaScript on error." }, + Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6007, category: DiagnosticCategory.Message, key: "Do not emit outputs if any type checking errors were reported." }, Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 94bbe966f30..cfb30775251 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1456,7 +1456,7 @@ "category": "Message", "code": 6006 }, - "Do not emit JavaScript on error.": { + "Do not emit outputs if any type checking errors were reported.": { "category": "Message", "code": 6007 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1517584e4c8..3ce39b95127 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3271,10 +3271,10 @@ module ts { } var hasSemanticErrors = resolver.hasSemanticErrors(); - var hasEarlyErrors = resolver.hasEarlyErrors(targetSourceFile); + var isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); function emitFile(jsFilePath: string, sourceFile?: SourceFile) { - if (!hasEarlyErrors) { + if (!isEmitBlocked) { emitJavaScript(jsFilePath, sourceFile); if (!hasSemanticErrors && compilerOptions.declaration) { emitDeclarations(jsFilePath, sourceFile); @@ -3318,7 +3318,7 @@ module ts { // Check and update returnCode for syntactic and semantic var returnCode: EmitReturnStatus; - if (hasEarlyErrors) { + if (isEmitBlocked) { returnCode = EmitReturnStatus.AllOutputGenerationSkipped; } else if (hasEmitterError) { returnCode = EmitReturnStatus.EmitErrorsEncountered; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index e578448457e..e5291c9d7f1 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -362,7 +362,7 @@ module ts { var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true); var checkStart = new Date().getTime(); errors = checker.getDiagnostics(); - if (checker.hasEarlyErrors() || (compilerOptions.noEmitOnError && errors.length > 0)) { + if (checker.isEmitBlocked()) { exitStatus = EmitReturnStatus.AllOutputGenerationSkipped; } else { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 07b230976ed..694294d2d12 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -666,7 +666,7 @@ module ts { isImplementationOfOverload(node: FunctionDeclaration): boolean; isUndefinedSymbol(symbol: Symbol): boolean; isArgumentsSymbol(symbol: Symbol): boolean; - hasEarlyErrors(sourceFile?: SourceFile): boolean; + isEmitBlocked(sourceFile?: SourceFile): boolean; // Returns the constant value of this enum member, or 'undefined' if the enum member has a // computed value. @@ -762,7 +762,7 @@ module ts { // Returns the constant value this property access resolves to, or 'undefined' if it does // resolve to a constant. getConstantValue(node: PropertyAccess): number; - hasEarlyErrors(sourceFile?: SourceFile): boolean; + isEmitBlocked(sourceFile?: SourceFile): boolean; } export enum SymbolFlags { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 60c5da5a1a6..e1735a6ad6d 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -796,16 +796,14 @@ module Harness { options.target, useCaseSensitiveFileNames)); - var hadParseErrors = program.getDiagnostics().length > 0; - var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true); checker.checkProgram(); - var hasEarlyErrors = checker.hasEarlyErrors(); + var isEmitBlocked = checker.isEmitBlocked(); // only emit if there weren't parse errors var emitResult: ts.EmitResult; - if (!hadParseErrors && !hasEarlyErrors) { + if (!isEmitBlocked) { emitResult = checker.emitFiles(); }