Skip to content

Commit 42d2339

Browse files
authored
Remove declares in sys, core, evaluatorImpl (#53176)
1 parent e775383 commit 42d2339

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

src/compiler/core.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,8 +2869,6 @@ function trimEndImpl(s: string) {
28692869
return s.slice(0, end + 1);
28702870
}
28712871

2872-
declare const process: any;
2873-
28742872
/** @internal */
28752873
export function isNodeLikeSystem(): boolean {
28762874
// This is defined here rather than in sys.ts to prevent a cycle from its
@@ -2880,7 +2878,7 @@ export function isNodeLikeSystem(): boolean {
28802878
// when bundled using esbuild, this function will be rewritten to `__require`
28812879
// and definitely exist.
28822880
return typeof process !== "undefined"
2883-
&& process.nextTick
2884-
&& !process.browser
2881+
&& !!process.nextTick
2882+
&& !(process as any).browser
28852883
&& typeof module === "object";
28862884
}

src/compiler/sys.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,12 +1443,6 @@ interface DirectoryWatcher extends FileWatcher {
14431443
referenceCount: number;
14441444
}
14451445

1446-
declare const require: any;
1447-
declare const process: any;
1448-
declare const global: any;
1449-
declare const __filename: string;
1450-
declare const __dirname: string;
1451-
14521446
// TODO: GH#18217 this is used as if it's certainly defined in many places.
14531447
export let sys: System = (() => {
14541448
// NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual
@@ -1507,7 +1501,7 @@ export let sys: System = (() => {
15071501
getAccessibleSortedChildDirectories: path => getAccessibleFileSystemEntries(path).directories,
15081502
realpath,
15091503
tscWatchFile: process.env.TSC_WATCHFILE,
1510-
useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
1504+
useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
15111505
tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
15121506
inodeWatching: isLinuxOrMacOs,
15131507
sysLog,
@@ -1584,7 +1578,7 @@ export let sys: System = (() => {
15841578
disableCPUProfiler,
15851579
cpuProfilingEnabled: () => !!activeSession || contains(process.execArgv, "--cpu-prof") || contains(process.execArgv, "--prof"),
15861580
realpath,
1587-
debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv as string[], arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)),
1581+
debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv, arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)),
15881582
tryEnableSourceMapsForHost() {
15891583
try {
15901584
(require("source-map-support") as typeof import("source-map-support")).install();
@@ -1599,8 +1593,9 @@ export let sys: System = (() => {
15991593
process.stdout.write("\x1Bc");
16001594
},
16011595
setBlocking: () => {
1602-
if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
1603-
process.stdout._handle.setBlocking(true);
1596+
const handle = (process.stdout as any)?._handle as { setBlocking?: (value: boolean) => void };
1597+
if (handle && handle.setBlocking) {
1598+
handle.setBlocking(true);
16041599
}
16051600
},
16061601
bufferFrom,

src/harness/evaluatorImpl.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import * as ts from "./_namespaces/ts";
55
import * as vfs from "./_namespaces/vfs";
66
import * as vpath from "./_namespaces/vpath";
77

8-
declare let Symbol: SymbolConstructor;
9-
108
const sourceFile = vpath.combine(vfs.srcFolder, "source.ts");
119
const sourceFileJs = vpath.combine(vfs.srcFolder, "source.js");
1210

0 commit comments

Comments
 (0)