Repository: denoland/deno
Pull request: fix(check): don't assert unique normalized specifiers

Fixes #29247.

Removes machinery added in #9357. That fix wasn't in effect anymore because `normalizedToOriginalMap` was duplicated in some refactor and one of them was dead code. And I doubt the underlying loading issue affecting `Deno.emit()` still exists.

Changed files:
filename: cli/tsc/97_ts_host.js
patch: @@ -23,15 +23,6 @@ function spanned(name, f) {
   }
 }
 
-// The map from the normalized specifier to the original.
-// TypeScript normalizes the specifier in its internal processing,
-// but the original specifier is needed when looking up the source from the runtime.
-// This map stores that relationship, and the original can be restored by the
-// normalized specifier.
-// See: https://github.com/denoland/deno/issues/9277#issuecomment-769653834
-/** @type {Map<string, string>} */
-const normalizedToOriginalMap = new Map();
-
 /** @type {ReadonlySet<string>} */
 const unstableDenoProps = new Set([
   "AtomicOperation",
@@ -88,7 +79,7 @@ export function setLogDebug(debug, source) {
 }
 
 /** @param msg {string} */
-function printStderr(msg) {
+export function printStderr(msg) {
   core.print(msg, true);
 }
 
@@ -471,9 +462,6 @@ const hostImpl = {
       );
     }
 
-    // Needs the original specifier
-    specifier = normalizedToOriginalMap.get(specifier) ?? specifier;
-
     let sourceFile = SOURCE_FILE_CACHE.get(specifier);
     if (sourceFile) {
       return sourceFile;

filename: cli/tsc/99_main_compiler.js
patch: @@ -13,7 +13,6 @@
 delete Object.prototype.__proto__;
 
 import {
-  AssertionError,
   debug,
   filterMapDiagnostic,
   fromTypeScriptDiagnostics,
@@ -26,15 +25,6 @@ import { serverMainLoop } from "./98_lsp.js";
 const core = globalThis.Deno.core;
 const ops = core.ops;
 
-// The map from the normalized specifier to the original.
-// TypeScript normalizes the specifier in its internal processing,
-// but the original specifier is needed when looking up the source from the runtime.
-// This map stores that relationship, and the original can be restored by the
-// normalized specifier.
-// See: https://github.com/denoland/deno/issues/9277#issuecomment-769653834
-/** @type {Map<string, string>} */
-const normalizedToOriginalMap = new Map();
-
 /** @type {Array<[string, number]>} */
 const stats = [];
 let statsStart = 0;
@@ -89,27 +79,6 @@ function performanceEnd() {
  * @property {boolean} localOnly
  */
 
-/**
- * Checks the normalized version of the root name and stores it in
- * `normalizedToOriginalMap`. If the normalized specifier is already
- * registered for the different root name, it throws an AssertionError.
- *
- * @param {string} rootName
- */
-function checkNormalizedPath(rootName) {
-  const normalized = ts.normalizePath(rootName);
-  const originalRootName = normalizedToOriginalMap.get(normalized);
-  if (typeof originalRootName === "undefined") {
-    normalizedToOriginalMap.set(normalized, rootName);
-  } else if (originalRootName !== rootName) {
-    // The different root names are normalizd to the same path.
-    // This will cause problem when looking up the source for each.
-    throw new AssertionError(
-      `The different names for the same normalized specifier are specified: normalized=${normalized}, rootNames=${originalRootName},${rootName}`,
-    );
-  }
-}
-
 /** @param {Record<string, unknown>} config */
 function normalizeConfig(config) {
   // the typescript compiler doesn't know about the precompile
@@ -135,8 +104,6 @@ function exec({ config, debug: debugFlag, rootNames, localOnly }) {
   debug(">>> exec start", { rootNames });
   debug(config);
 
-  rootNames.forEach(checkNormalizedPath);
-
   const { options, errors: configFileParsingDiagnostics } = ts
     .convertCompilerOptionsFromJson(config, "");
   // The `allowNonTsExtensions` is a "hidden" compiler option used in VSCode

filename: tests/specs/check/check_non_normalized_specifier/__test__.jsonc
patch: @@ -0,0 +1,5 @@
+{
+  "args": "check --quiet",
+  "output": "",
+  "exitCode": 0
+}

filename: tests/specs/check/check_non_normalized_specifier/main.ts
patch: @@ -0,0 +1 @@
+import ".//other.ts";