From 7dac09291e17a851c8503c762fca566af9a75d58 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 1 Apr 2025 13:29:57 +0300 Subject: [PATCH 1/2] repl: filter out module names that contain colon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These would otherwise result in syntax like `… node:sea = …`, which causes further problems with indefinite wait. Fixes: https://github.com/TypeStrong/ts-node/issues/2150 --- src/repl.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/repl.ts b/src/repl.ts index bb1abe83b..2271d3d26 100644 --- a/src/repl.ts +++ b/src/repl.ts @@ -376,7 +376,7 @@ export function createRepl(options: CreateReplOptions = {}) { // Declare node builtins. // Skip the same builtins as `addBuiltinLibsToObject`: // those starting with _ - // those containing / + // those containing / or : // those that already exist as globals // Intentionally suppress type errors in case @types/node does not declare any of them, and because // `declare import` is technically invalid syntax. @@ -384,7 +384,8 @@ export function createRepl(options: CreateReplOptions = {}) { if (!service?.transpileOnly) { state.input += `// @ts-ignore\n${builtinModules .filter( - (name) => !name.startsWith('_') && !name.includes('/') && !['console', 'module', 'process'].includes(name) + (name) => (!name.startsWith('_') && !name.includes('/') && !name.includes(':') + && !['console', 'module', 'process'].includes(name)) ) .map((name) => `declare import ${name} = require('${name}')`) .join(';')}\n`; From ad1fc859958d420f3a4278102afa5c3757ac1e67 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 1 Apr 2025 13:32:56 +0300 Subject: [PATCH 2/2] =?UTF-8?q?repl:=20simplify=20"not=20and=20not=20?= =?UTF-8?q?=E2=80=A6"=20chain=20per=20De=20Morgan's?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit De Morgan's rule: `(not a) and (not b) = not (a or b)` --- src/repl.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/repl.ts b/src/repl.ts index 2271d3d26..2b2cee04e 100644 --- a/src/repl.ts +++ b/src/repl.ts @@ -384,8 +384,8 @@ export function createRepl(options: CreateReplOptions = {}) { if (!service?.transpileOnly) { state.input += `// @ts-ignore\n${builtinModules .filter( - (name) => (!name.startsWith('_') && !name.includes('/') && !name.includes(':') - && !['console', 'module', 'process'].includes(name)) + (name) => !(name.startsWith('_') || name.includes('/') || name.includes(':') + || ['console', 'module', 'process'].includes(name)) ) .map((name) => `declare import ${name} = require('${name}')`) .join(';')}\n`;