diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 597b323661f..1acb342daa4 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2869,8 +2869,6 @@ function trimEndImpl(s: string) { return s.slice(0, end + 1); } -declare const process: any; - /** @internal */ export function isNodeLikeSystem(): boolean { // This is defined here rather than in sys.ts to prevent a cycle from its @@ -2880,7 +2878,7 @@ export function isNodeLikeSystem(): boolean { // when bundled using esbuild, this function will be rewritten to `__require` // and definitely exist. return typeof process !== "undefined" - && process.nextTick - && !process.browser + && !!process.nextTick + && !(process as any).browser && typeof module === "object"; } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 547bcd680a0..45e456454bc 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -1443,12 +1443,6 @@ interface DirectoryWatcher extends FileWatcher { referenceCount: number; } -declare const require: any; -declare const process: any; -declare const global: any; -declare const __filename: string; -declare const __dirname: string; - // TODO: GH#18217 this is used as if it's certainly defined in many places. export let sys: System = (() => { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual @@ -1507,7 +1501,7 @@ export let sys: System = (() => { getAccessibleSortedChildDirectories: path => getAccessibleFileSystemEntries(path).directories, realpath, tscWatchFile: process.env.TSC_WATCHFILE, - useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, + useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, inodeWatching: isLinuxOrMacOs, sysLog, @@ -1584,7 +1578,7 @@ export let sys: System = (() => { disableCPUProfiler, cpuProfilingEnabled: () => !!activeSession || contains(process.execArgv, "--cpu-prof") || contains(process.execArgv, "--prof"), realpath, - debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv as string[], arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)), + debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv, arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)), tryEnableSourceMapsForHost() { try { (require("source-map-support") as typeof import("source-map-support")).install(); @@ -1599,8 +1593,9 @@ export let sys: System = (() => { process.stdout.write("\x1Bc"); }, setBlocking: () => { - if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) { - process.stdout._handle.setBlocking(true); + const handle = (process.stdout as any)?._handle as { setBlocking?: (value: boolean) => void }; + if (handle && handle.setBlocking) { + handle.setBlocking(true); } }, bufferFrom, diff --git a/src/harness/evaluatorImpl.ts b/src/harness/evaluatorImpl.ts index 0f922794560..f72526fb4a1 100644 --- a/src/harness/evaluatorImpl.ts +++ b/src/harness/evaluatorImpl.ts @@ -5,8 +5,6 @@ import * as ts from "./_namespaces/ts"; import * as vfs from "./_namespaces/vfs"; import * as vpath from "./_namespaces/vpath"; -declare let Symbol: SymbolConstructor; - const sourceFile = vpath.combine(vfs.srcFolder, "source.ts"); const sourceFileJs = vpath.combine(vfs.srcFolder, "source.js");