Skip to content

Commit f300ebb

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

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

lib/internal/process/execution.js

Lines changed: 6 additions & 21 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,10 +317,6 @@ 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-
}
332320
let strippedSource;
333321
try {
334322
strippedSource = stripTypeScriptModuleTypes(source, url, false);
@@ -340,12 +328,9 @@ function evalTypeScriptModuleEntryPoint(source, print) {
340328
} catch (tsError) {
341329
// If it's invalid or unsupported TypeScript syntax, rethrow the original error
342330
// 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 */ }
331+
if (tsError.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX' ||
332+
tsError.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX') {
333+
originalError.stack = `${tsError.message}\n\n${originalError.stack}`;
349334
throw originalError;
350335
}
351336

0 commit comments

Comments
 (0)