mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge pull request #2431 from Microsoft/noEmitOnErrorCompileOnSave
No emit should happen if there are declaration errors and noEmitOnErrors is specified.
This commit is contained in:
commit
0d2a5bbf7c
@ -122,8 +122,10 @@ module ts {
|
||||
}
|
||||
|
||||
export function addRange<T>(to: T[], from: T[]): void {
|
||||
for (let v of from) {
|
||||
to.push(v);
|
||||
if (to && from) {
|
||||
for (let v of from) {
|
||||
to.push(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -87,6 +87,11 @@ module ts {
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program): Diagnostic[] {
|
||||
let diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics());
|
||||
|
||||
if (program.getCompilerOptions().declaration) {
|
||||
diagnostics.concat(program.getDeclarationDiagnostics());
|
||||
}
|
||||
|
||||
return sortAndDeduplicateDiagnostics(diagnostics);
|
||||
}
|
||||
|
||||
@ -178,11 +183,6 @@ module ts {
|
||||
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false));
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(targetSourceFile: SourceFile): Diagnostic[] {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile);
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile);
|
||||
}
|
||||
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult {
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out.
|
||||
@ -232,6 +232,10 @@ module ts {
|
||||
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile);
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile);
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
return sourceFile.parseDiagnostics;
|
||||
}
|
||||
@ -247,6 +251,15 @@ module ts {
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
var writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
|
||||
@ -1005,14 +1005,14 @@ module ts {
|
||||
getSourceFiles(): SourceFile[];
|
||||
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
|
||||
|
||||
@ -4914,7 +4914,6 @@ module ts {
|
||||
synchronizeHostData();
|
||||
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
let outputFiles: OutputFile[] = [];
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
|
||||
@ -801,14 +801,14 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
|
||||
@ -2440,14 +2440,14 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
>emit : (targetSourceFile?: SourceFile, writeFile?: WriteFileCallback) => EmitResult
|
||||
|
||||
@ -832,14 +832,14 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
|
||||
@ -2586,14 +2586,14 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
>emit : (targetSourceFile?: SourceFile, writeFile?: WriteFileCallback) => EmitResult
|
||||
|
||||
@ -833,14 +833,14 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
|
||||
@ -2536,14 +2536,14 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
>emit : (targetSourceFile?: SourceFile, writeFile?: WriteFileCallback) => EmitResult
|
||||
|
||||
@ -870,14 +870,14 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
|
||||
@ -2709,14 +2709,14 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
>emit : (targetSourceFile?: SourceFile, writeFile?: WriteFileCallback) => EmitResult
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user