Skip to content

Commit f67762a

Browse files
fixup! remove dead code
1 parent 526ece0 commit f67762a

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

lib/internal/process/execution.js

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const { getOptionValue } = require('internal/options');
3535
const {
3636
makeContextifyScript, runScriptInThisContext,
3737
} = require('internal/vm');
38-
const { emitExperimentalWarning, isError } = require('internal/util');
38+
const { emitExperimentalWarning } = require('internal/util');
3939
// shouldAbortOnUncaughtToggle is a typed array for faster
4040
// communication with JS.
4141
const { shouldAbortOnUncaughtToggle } = internalBinding('util');
@@ -254,10 +254,6 @@ function evalTypeScript(name, source, breakFirstLine, print, shouldLoadESM = fal
254254
try {
255255
compiledScript = compileScript(name, source, baseUrl);
256256
} catch (originalError) {
257-
// If it's not a SyntaxError, rethrow it.
258-
if (!isError(originalError) || originalError.name !== 'SyntaxError') {
259-
throw originalError;
260-
}
261257
try {
262258
sourceToRun = stripTypeScriptModuleTypes(source, name, false);
263259
// Retry the CJS/ESM syntax detection after stripping the types.
@@ -272,12 +268,8 @@ function evalTypeScript(name, source, breakFirstLine, print, shouldLoadESM = fal
272268
} catch (tsError) {
273269
// If it's invalid or unsupported TypeScript syntax, rethrow the original error
274270
// with the TypeScript error message added to the stack.
275-
const isInvalidTS = tsError?.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX';
276-
const isUnsupportedTS = tsError?.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX';
277-
if ((isInvalidTS || isUnsupportedTS) && isError(tsError)) {
278-
try {
279-
originalError.stack = decorateCJSErrorWithTSMessage(originalError.stack, tsError.message);
280-
} catch { /* Ignore potential errors coming from `stack` getter/setter */ }
271+
if (tsError.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX' || tsError.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX') {
272+
originalError.stack = decorateCJSErrorWithTSMessage(originalError.stack, tsError.message);
281273
throw originalError;
282274
}
283275

@@ -325,13 +317,8 @@ function evalTypeScriptModuleEntryPoint(source, print) {
325317
// Compile the module to check for syntax errors.
326318
moduleWrap = loader.createModuleWrap(source, url);
327319
} catch (originalError) {
328-
// If it's not a SyntaxError, rethrow it.
329-
if (!isError(originalError) || originalError.name !== 'SyntaxError') {
330-
throw originalError;
331-
}
332-
let strippedSource;
333320
try {
334-
strippedSource = stripTypeScriptModuleTypes(source, url, false);
321+
const strippedSource = stripTypeScriptModuleTypes(source, url, false);
335322
// If the moduleWrap was successfully created, execute the module job.
336323
// outside the try-catch block to avoid catching runtime errors.
337324
moduleWrap = loader.createModuleWrap(strippedSource, url);
@@ -340,12 +327,9 @@ function evalTypeScriptModuleEntryPoint(source, print) {
340327
} catch (tsError) {
341328
// If it's invalid or unsupported TypeScript syntax, rethrow the original error
342329
// with the TypeScript error message added to the stack.
343-
const isInvalidTS = tsError?.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX';
344-
const isUnsupportedTS = tsError?.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX';
345-
if ((isInvalidTS || isUnsupportedTS) && isError(tsError)) {
346-
try {
347-
originalError.stack = `${tsError.message}\n\n${originalError.stack}`;
348-
} catch { /* Ignore potential errors coming from `stack` getter/setter */ }
330+
if (tsError.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX' ||
331+
tsError.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX') {
332+
originalError.stack = `${tsError.message}\n\n${originalError.stack}`;
349333
throw originalError;
350334
}
351335

0 commit comments

Comments
 (0)