Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/typescript/internal/worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function emitOnce(args) {
consolidateChangesCallback();
}
workerRequestTimestamp = Date.now();
const result = yield (watchProgram === null || watchProgram === void 0 ? void 0 : watchProgram.getProgram().emit(undefined, undefined, {
const program = watchProgram === null || watchProgram === void 0 ? void 0 : watchProgram.getProgram();
const cancellationToken = {
isCancellationRequested: function (timestamp) {
return timestamp !== workerRequestTimestamp;
}.bind(null, workerRequestTimestamp),
Expand All @@ -66,8 +67,11 @@ function emitOnce(args) {
throw new ts.OperationCanceledException();
}
}.bind(null, workerRequestTimestamp),
}));
return Boolean(result && result.diagnostics.length === 0);
};
const result = program.emit(undefined, undefined, cancellationToken);
const diagnostics = ts.getPreEmitDiagnostics(program, undefined, cancellationToken);
let succeded = result && result.diagnostics.length === 0 && diagnostics.length == 0;
return succeded;
});
}
function main() {
Expand Down
13 changes: 8 additions & 5 deletions packages/typescript/internal/worker/worker_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ async function emitOnce(args: string[]) {
consolidateChangesCallback();
}


workerRequestTimestamp = Date.now();
const result = await watchProgram ?.getProgram().emit(undefined, undefined, {
const program = watchProgram?.getProgram()
const cancellationToken: ts.CancellationToken = {
isCancellationRequested: function(timestamp: number) {
return timestamp !== workerRequestTimestamp;
}.bind(null, workerRequestTimestamp),
Expand All @@ -110,9 +110,12 @@ async function emitOnce(args: string[]) {
throw new ts.OperationCanceledException();
}
}.bind(null, workerRequestTimestamp),
});

return Boolean(result && result.diagnostics.length === 0);
}

const result = program.emit(undefined, undefined, cancellationToken);
const diagnostics = ts.getPreEmitDiagnostics(program as unknown as ts.Program, undefined, cancellationToken)
let succeded = result && result.diagnostics.length === 0 && diagnostics.length == 0
return succeded
}

function main() {
Expand Down