addressed feedback

This commit is contained in:
Dick van den Brink
2014-10-28 19:45:18 +01:00
parent bd2c5965f5
commit e4f57569b7
8 changed files with 19 additions and 15 deletions
+8 -2
View File
@@ -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,
+1 -1
View File
@@ -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",
@@ -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'" },
+1 -1
View File
@@ -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
},
+3 -3
View File
@@ -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;
+1 -1
View File
@@ -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 {
+2 -2
View File
@@ -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 {
+2 -4
View File
@@ -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();
}