This commit is contained in:
Sheetal Nandi 2019-01-17 12:29:23 -08:00
parent dbae2cba47
commit 900d6f7c90
2 changed files with 8 additions and 8 deletions

View file

@ -516,11 +516,11 @@ namespace ts {
const result = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
result.getState = () => state;
result.backupCurrentState = () => {
result.backupState = () => {
Debug.assert(backupState === undefined);
backupState = cloneBuilderProgramState(state);
};
result.useBackupState = () => {
result.restoreState = () => {
state = Debug.assertDefined(backupState);
backupState = undefined;
};
@ -715,8 +715,8 @@ namespace ts {
export function createRedirectedBuilderProgram(state: { program: Program | undefined; compilerOptions: CompilerOptions; }, configFileParsingDiagnostics: ReadonlyArray<Diagnostic>): BuilderProgram {
return {
getState: notImplemented,
backupCurrentState: noop,
useBackupState: noop,
backupState: noop,
restoreState: noop,
getProgram,
getProgramOrUndefined: () => state.program,
releaseProgram: () => state.program = undefined,
@ -766,9 +766,9 @@ namespace ts {
/*@internal*/
getState(): BuilderProgramState;
/*@internal*/
backupCurrentState(): void;
backupState(): void;
/*@internal*/
useBackupState(): void;
restoreState(): void;
/**
* Returns current program
*/

View file

@ -1129,7 +1129,7 @@ namespace ts {
}
// Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly
program.backupCurrentState();
program.backupState();
let newestDeclarationFileContentChangedTime = minimumDate;
let anyDtsChanged = false;
let declDiagnostics: Diagnostic[] | undefined;
@ -1138,7 +1138,7 @@ namespace ts {
emitFilesAndReportErrors(program, reportDeclarationDiagnostics, writeFileName, /*reportSummary*/ undefined, (name, text, writeByteOrderMark) => outputFiles.push({ name, text, writeByteOrderMark }));
// Don't emit .d.ts if there are decl file errors
if (declDiagnostics) {
program.useBackupState();
program.restoreState();
return buildErrors(declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file");
}