Skip to content

Commit

Permalink
fixup! remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Jan 15, 2025
1 parent 526ece0 commit f67762a
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions lib/internal/process/execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const { getOptionValue } = require('internal/options');
const {
makeContextifyScript, runScriptInThisContext,
} = require('internal/vm');
const { emitExperimentalWarning, isError } = require('internal/util');
const { emitExperimentalWarning } = require('internal/util');
// shouldAbortOnUncaughtToggle is a typed array for faster
// communication with JS.
const { shouldAbortOnUncaughtToggle } = internalBinding('util');
Expand Down Expand Up @@ -254,10 +254,6 @@ function evalTypeScript(name, source, breakFirstLine, print, shouldLoadESM = fal
try {
compiledScript = compileScript(name, source, baseUrl);
} catch (originalError) {
// If it's not a SyntaxError, rethrow it.
if (!isError(originalError) || originalError.name !== 'SyntaxError') {
throw originalError;
}
try {
sourceToRun = stripTypeScriptModuleTypes(source, name, false);
// Retry the CJS/ESM syntax detection after stripping the types.
Expand All @@ -272,12 +268,8 @@ function evalTypeScript(name, source, breakFirstLine, print, shouldLoadESM = fal
} catch (tsError) {
// If it's invalid or unsupported TypeScript syntax, rethrow the original error
// with the TypeScript error message added to the stack.
const isInvalidTS = tsError?.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX';
const isUnsupportedTS = tsError?.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX';
if ((isInvalidTS || isUnsupportedTS) && isError(tsError)) {
try {
originalError.stack = decorateCJSErrorWithTSMessage(originalError.stack, tsError.message);
} catch { /* Ignore potential errors coming from `stack` getter/setter */ }
if (tsError.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX' || tsError.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX') {
originalError.stack = decorateCJSErrorWithTSMessage(originalError.stack, tsError.message);
throw originalError;
}

Expand Down Expand Up @@ -325,13 +317,8 @@ function evalTypeScriptModuleEntryPoint(source, print) {
// Compile the module to check for syntax errors.
moduleWrap = loader.createModuleWrap(source, url);
} catch (originalError) {
// If it's not a SyntaxError, rethrow it.
if (!isError(originalError) || originalError.name !== 'SyntaxError') {
throw originalError;
}
let strippedSource;
try {
strippedSource = stripTypeScriptModuleTypes(source, url, false);
const strippedSource = stripTypeScriptModuleTypes(source, url, false);
// If the moduleWrap was successfully created, execute the module job.
// outside the try-catch block to avoid catching runtime errors.
moduleWrap = loader.createModuleWrap(strippedSource, url);
Expand All @@ -340,12 +327,9 @@ function evalTypeScriptModuleEntryPoint(source, print) {
} catch (tsError) {
// If it's invalid or unsupported TypeScript syntax, rethrow the original error
// with the TypeScript error message added to the stack.
const isInvalidTS = tsError?.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX';
const isUnsupportedTS = tsError?.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX';
if ((isInvalidTS || isUnsupportedTS) && isError(tsError)) {
try {
originalError.stack = `${tsError.message}\n\n${originalError.stack}`;
} catch { /* Ignore potential errors coming from `stack` getter/setter */ }
if (tsError.code === 'ERR_INVALID_TYPESCRIPT_SYNTAX' ||
tsError.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX') {
originalError.stack = `${tsError.message}\n\n${originalError.stack}`;
throw originalError;
}

Expand Down

0 comments on commit f67762a

Please sign in to comment.