From cc460dc32724c366a0d0e128088459009f9ec594 Mon Sep 17 00:00:00 2001
From: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Date: Tue, 19 Mar 2024 13:54:17 -0700
Subject: [PATCH] Revert PR 56087 (#57849)

---
 src/compiler/checker.ts                       |  6 ----
 .../declarationEmitUsingTypeAlias1.errors.txt | 34 +++++++++++++++++++
 .../declarationEmitUsingTypeAlias1.js         |  6 ----
 ...arametersCheckedByNoUnusedParameters.types |  4 ---
 ...ParametersNotCheckedByNoUnusedLocals.types |  4 ---
 5 files changed, 34 insertions(+), 20 deletions(-)
 create mode 100644 tests/baselines/reference/declarationEmitUsingTypeAlias1.errors.txt

diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 8ba4d7d896f8b..0c5af109e5b32 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -5740,12 +5740,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
      * Checks if two symbols, through aliasing and/or merging, refer to the same thing
      */
     function getSymbolIfSameReference(s1: Symbol, s2: Symbol) {
-        if (s1.flags & SymbolFlags.TypeAlias && s2.declarations?.find(isTypeAlias)) {
-            s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
-        }
-        if (s2.flags & SymbolFlags.TypeAlias && s1.declarations?.find(isTypeAlias)) {
-            s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
-        }
         if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
             return s1;
         }
diff --git a/tests/baselines/reference/declarationEmitUsingTypeAlias1.errors.txt b/tests/baselines/reference/declarationEmitUsingTypeAlias1.errors.txt
new file mode 100644
index 0000000000000..c31e66a237a62
--- /dev/null
+++ b/tests/baselines/reference/declarationEmitUsingTypeAlias1.errors.txt
@@ -0,0 +1,34 @@
+src/index.ts(3,14): error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.
+src/index.ts(7,14): error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.
+
+
+==== node_modules/some-dep/dist/inner.d.ts (0 errors) ====
+    export declare type Other = { other: string };
+    export declare type SomeType = { arg: Other };
+    
+==== node_modules/some-dep/dist/index.d.ts (0 errors) ====
+    export type OtherType = import('./inner').Other;
+    export type SomeType = import('./inner').SomeType;
+    
+==== node_modules/some-dep/package.json (0 errors) ====
+    {
+      "name": "some-dep",
+      "exports": {
+        ".": "./dist/index.js"
+      }
+    }
+    
+==== src/index.ts (2 errors) ====
+    import { SomeType } from "some-dep";
+    
+    export const foo = (thing: SomeType) => {
+                 ~~~
+!!! error TS2742: The inferred type of 'foo' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.
+      return thing;
+    };
+    
+    export const bar = (thing: SomeType) => {
+                 ~~~
+!!! error TS2742: The inferred type of 'bar' cannot be named without a reference to '../node_modules/some-dep/dist/inner'. This is likely not portable. A type annotation is necessary.
+      return thing.arg;
+    };
\ No newline at end of file
diff --git a/tests/baselines/reference/declarationEmitUsingTypeAlias1.js b/tests/baselines/reference/declarationEmitUsingTypeAlias1.js
index 29db9047f7321..c243d425a035e 100644
--- a/tests/baselines/reference/declarationEmitUsingTypeAlias1.js
+++ b/tests/baselines/reference/declarationEmitUsingTypeAlias1.js
@@ -39,9 +39,3 @@ const bar = (thing) => {
     return thing.arg;
 };
 exports.bar = bar;
-
-
-//// [index.d.ts]
-import { SomeType } from "some-dep";
-export declare const foo: (thing: SomeType) => import("some-dep").SomeType;
-export declare const bar: (thing: SomeType) => import("some-dep").OtherType;
diff --git a/tests/baselines/reference/unusedTypeParametersCheckedByNoUnusedParameters.types b/tests/baselines/reference/unusedTypeParametersCheckedByNoUnusedParameters.types
index 20865d5a13c35..55af55a808723 100644
--- a/tests/baselines/reference/unusedTypeParametersCheckedByNoUnusedParameters.types
+++ b/tests/baselines/reference/unusedTypeParametersCheckedByNoUnusedParameters.types
@@ -1,9 +1,5 @@
 //// [tests/cases/compiler/unusedTypeParametersCheckedByNoUnusedParameters.ts] ////
 
-=== Performance Stats ===
-Type Count: 100 / 3,200 (nearest 100)
-Symbol count: 25,500 / 25,500 (nearest 500)
-
 === unusedTypeParametersCheckedByNoUnusedParameters.ts ===
 function f<T>() { }
 >f : <T>() => void
diff --git a/tests/baselines/reference/unusedTypeParametersNotCheckedByNoUnusedLocals.types b/tests/baselines/reference/unusedTypeParametersNotCheckedByNoUnusedLocals.types
index b2b35fcfa212e..e21a6f2b7f3f0 100644
--- a/tests/baselines/reference/unusedTypeParametersNotCheckedByNoUnusedLocals.types
+++ b/tests/baselines/reference/unusedTypeParametersNotCheckedByNoUnusedLocals.types
@@ -1,9 +1,5 @@
 //// [tests/cases/compiler/unusedTypeParametersNotCheckedByNoUnusedLocals.ts] ////
 
-=== Performance Stats ===
-Type Count: 100 / 3,200 (nearest 100)
-Symbol count: 25,500 / 25,500 (nearest 500)
-
 === unusedTypeParametersNotCheckedByNoUnusedLocals.ts ===
 function f<T>() { }
 >f : <T>() => void