Skip to content

Commit 85df31c

Browse files
authored
Merge pull request microsoft#22512 from Microsoft/fixUseOfProcess
Do not use unguarded process in tsc.ts
2 parents 32018f6 + 708caf9 commit 85df31c

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/compiler/sys.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ namespace ts {
456456
setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
457457
clearTimeout?(timeoutId: any): void;
458458
clearScreen?(): void;
459+
/*@internal*/ setBlocking?(): void;
459460
}
460461

461462
export interface FileWatcher {
@@ -614,6 +615,11 @@ namespace ts {
614615
clearTimeout,
615616
clearScreen: () => {
616617
process.stdout.write("\x1Bc");
618+
},
619+
setBlocking: () => {
620+
if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
621+
process.stdout._handle.setBlocking(true);
622+
}
617623
}
618624
};
619625
return nodeSystem;

src/compiler/tsc.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,9 @@ if (ts.Debug.isDebugging) {
399399
if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
400400
ts.sys.tryEnableSourceMapsForHost();
401401
}
402-
declare var process: any;
403-
if (process && process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
404-
process.stdout._handle.setBlocking(true);
402+
403+
if (ts.sys.setBlocking) {
404+
ts.sys.setBlocking();
405405
}
406+
406407
ts.executeCommandLine(ts.sys.args);

0 commit comments

Comments
 (0)