Skip to content

Commit

Permalink
🤖 Pick PR #53174 (Remove old references to Node v4, s...) into releas…
Browse files Browse the repository at this point in the history
…e-5.0 (#53189)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
  • Loading branch information
TypeScript Bot and jakebailey authored Mar 14, 2023
1 parent 6e59874 commit d97bb67
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 26 deletions.
19 changes: 1 addition & 18 deletions src/compiler/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1449,21 +1449,6 @@ declare const global: any;
declare const __filename: string;
declare const __dirname: string;

export function getNodeMajorVersion(): number | undefined {
if (typeof process === "undefined") {
return undefined;
}
const version: string = process.version;
if (!version) {
return undefined;
}
const dot = version.indexOf(".");
if (dot === -1) {
return undefined;
}
return parseInt(version.substring(1, dot));
}

// TODO: GH#18217 this is used as if it's certainly defined in many places.
// eslint-disable-next-line prefer-const
export let sys: System = (() => {
Expand Down Expand Up @@ -1493,8 +1478,6 @@ export let sys: System = (() => {
from?(input: string, encoding?: string): any;
} = require("buffer").Buffer;

const nodeVersion = getNodeMajorVersion();
const isNode4OrLater = nodeVersion! >= 4;
const isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";

const platform: string = _os.platform();
Expand All @@ -1508,7 +1491,7 @@ export let sys: System = (() => {
// Note that if we ever emit as files like cjs/mjs, this check will be wrong.
const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;

const fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
const fsSupportsRecursiveFsWatch = process.platform === "win32" || process.platform === "darwin";
const getCurrentDirectory = memoize(() => process.cwd());
const { watchFile, watchDirectory } = createSystemWatchFunctions({
pollingWatchFileWorker: fsWatchFileWorker,
Expand Down
5 changes: 1 addition & 4 deletions src/tsserver/nodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DirectoryWatcherCallback,
FileWatcher,
getDirectoryPath,
getNodeMajorVersion,
getRootLength,
JsTyping,
LanguageServiceMode,
Expand Down Expand Up @@ -299,9 +298,7 @@ export function initializeNodeSystem(): StartInput {

const libDirectory = getDirectoryPath(normalizePath(sys.getExecutingFilePath()));

const nodeVersion = getNodeMajorVersion();
// use watchGuard process on Windows when node version is 4 or later
const useWatchGuard = process.platform === "win32" && nodeVersion! >= 4;
const useWatchGuard = process.platform === "win32";
const originalWatchDirectory: ServerHost["watchDirectory"] = sys.watchDirectory.bind(sys);
const logger = createLogger();

Expand Down
3 changes: 1 addition & 2 deletions src/tsserver/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Debug,
getNodeMajorVersion,
setStackTraceLimit,
sys,
version,
Expand Down Expand Up @@ -30,7 +29,7 @@ function start({ args, logger, cancellationToken, serverMode, unknownServerMode,
logger.info(`Starting TS Server`);
logger.info(`Version: ${version}`);
logger.info(`Arguments: ${args.join(" ")}`);
logger.info(`Platform: ${platform} NodeVersion: ${getNodeMajorVersion()} CaseSensitive: ${sys.useCaseSensitiveFileNames}`);
logger.info(`Platform: ${platform} NodeVersion: ${process.version} CaseSensitive: ${sys.useCaseSensitiveFileNames}`);
logger.info(`ServerMode: ${serverMode} hasUnknownServerMode: ${unknownServerMode}`);

setStackTraceLimit();
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8286,7 +8286,6 @@ declare namespace ts {
negative: boolean;
base10Value: string;
}
function getNodeMajorVersion(): number | undefined;
enum FileWatcherEventKind {
Created = 0,
Changed = 1,
Expand Down
1 change: 0 additions & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4311,7 +4311,6 @@ declare namespace ts {
negative: boolean;
base10Value: string;
}
function getNodeMajorVersion(): number | undefined;
enum FileWatcherEventKind {
Created = 0,
Changed = 1,
Expand Down

0 comments on commit d97bb67

Please sign in to comment.