Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jan 31, 2025
1 parent f92dacd commit e9a7752
Showing 1 changed file with 5 additions and 59 deletions.
64 changes: 5 additions & 59 deletions cli/tsc/97_ts_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,22 +744,6 @@ ts.setLocalizedDiagnosticMessages((() => {
};
})());

/** @param {ts.Diagnostic} diagnostic */
function isLibDiagnostic(diagnostic) {
return diagnostic.file?.fileName.startsWith("asset:///") ||
diagnostic.file?.fileName?.includes("@types/node");
}

/** @param {ts.DiagnosticMessageChain | string} messageText */
function getTopLevelMessageText(messageText) {
if (typeof messageText === "string") {
return messageText;
} else if (typeof messageText.messageText === "string") {
return messageText.messageText;
}
return undefined;
}

/** @param {ts.Diagnostic} diagnostic */
export function filterMapDiagnostic(diagnostic) {
if (IGNORED_DIAGNOSTICS.includes(diagnostic.code)) {
Expand All @@ -780,51 +764,9 @@ export function filterMapDiagnostic(diagnostic) {
}
}

// // allow assigning a globalThis.URL to "node:url".URL
// if (
// checkDiagnosticAndChain(diagnostic, (d) => {
// return d.code === 2322 && d.messageText ===
// "Type 'URL' is not assignable to type 'import(\"url\").URL'.";
// })
// ) {
// return false;
// }

return true;
}

/**
* @param {ts.Diagnostic} diagnostic
* @param {(d: { code: number, messageText: string }) => boolean} check
*/
function checkDiagnosticAndChain(diagnostic, check) {
if (typeof diagnostic.messageText === "string") {
return check(
/** @type {{ code: number, messageText: string }} */ (diagnostic),
);
} else {
return checkDiagnosticMessageChain(diagnostic.messageText, check);
}
}

/**
* @param {ts.DiagnosticMessageChain} dmc
* @param {(d: ts.DiagnosticMessageChain) => boolean} check
*/
function checkDiagnosticMessageChain(dmc, check) {
if (check(dmc)) {
return true;
}
if (dmc.next) {
for (const next of dmc.next) {
if (checkDiagnosticMessageChain(next, check)) {
return true;
}
}
}
return false;
}

// list of globals that should be kept in Node's globalThis
ts.deno.setNodeOnlyGlobalNames(
new Set([
Expand Down Expand Up @@ -853,7 +795,11 @@ ts.deno.setNodeOnlyGlobalNames(
"setTimeout",
]),
);
// list of globals in @types/node that collide with Deno
// List of globals in @types/node that collide with Deno's types.
// When the `@types/node` package attempts to assign to these types
// if the type is already in the global symbol table, then assignment
// will be a no-op, but if the global type does not exist then the package can
// create the global.
const setTypesNodeIgnorableNames = new Set([
"AbortController",
"AbortSignal",
Expand Down

0 comments on commit e9a7752

Please sign in to comment.