Repository: TypeScript
Issue: Tooltip types vary depending on if type is imported or locally defined
Labels: Suggestion,Help Wanted,Experience Enhancement

# Bug Report

### 🔎 Search Terms

hover different import undefined optional parameter

### 🕗 Version & Regression Information

- This changed between versions 4.6.4 and 4.7.4
- Nightly version at time of test: 4.9.0-dev.20221025

### ⏯ Playground Link

[Playground Workbench Repro](https://www.typescriptlang.org/dev/bug-workbench/?ts=4.7.4#code/PTAEAEDMEsBsFMB2BDAtvAXKaiAOBXAFwDpCBnAKHgA9cB7AJ0O0UPgcmQGN5QBZAJ4B5AEYAreF2YBvCqFBl8I0RKlZZ8+YKEA3drDrIAJvCMAxRAAo6uQtDopYAZUIMcAcwD8WMq48BKLER8VBF2AG45TW09BgNjUwtrW3tHADkQsIZvUGDQ9gAaUBs7B2RnP0QvH0r3QNzMiKiAX0jmikIBXF4ACTpYgFFqNFwEAEZQAF5+YXFJQgBtAHJFZTmpJYBdSOAAKl3QIURQAAt+9gwOrt7zhiGR8anQDWjhWPiTcysS1PKXNyqOV8ALqQUaDEimhmun0hk+SR+ZVgGXy2TBqKKiMc-w8QNq9TyWTaFAoIAAksdCCdeHQqexQDAEJdOt1QH1BsNUKN4AAmJ4vLRvWEJL7JUrY2p4kGgAA+oHwiBMMEQpgJ4MhrxhcThiW+KSRKKyOUJ9LlCqVOFMmP1EpBUo8svlivgytV6KJFHau2AJJAEEZSDQmAZcF5pEo0C5jGYLN40mh62YzQZDDoqFAS2IwBwBEIS3CoCurPZ7HuXIQfOm2kTy1WKnmW0iQA)


### 💻 Code
```ts repro
// @filename: input.ts
export interface MyObject {
  subObject: {
    MyOverloadedFn(optionalString?: string): number;
    MyOverloadedFn(optionalNumber?: number, optionalString?: string): number;
  };
}
type HoverExample1 = MyObject['subObject'];
/** On hover:
type HoverExample1 = {
    MyOverloadedFn(optionalString?: string): number;
    MyOverloadedFn(optionalNumber?: number, optionalString?: string): number;
}

//In the other file:
type HoverExample2 = {
    MyOverloadedFn(optionalString?: string | undefined): number;
    MyOverloadedFn(optionalNumber?: number | undefined, optionalString?: string | undefined): number;
}
*/

// @filename: file2.ts
import type { MyObject } from './input'; 
type HoverExample2 = MyObject['subObject'];

```

### 🙁 Actual behavior
As noted in the comments, the type shown on hover is different depending on if the type is defined locally or imported from another file.  Recently I came across a separate issue with an error report that reads a lot like "T is not assignable to T" with a particular focus on that `| undefined` bit as a possible cause. I tried copying relevant portions of code into a demonstration file to try to come up with a more minimal reproducible example of that error and wound up producing a different error instead. On trying to investigate why, I found this difference between the type in the simpler reproduction-attempt example (where the type is defined locally) and the real-world example (where it is imported) and that led me down a long rabbit-hole of confusion about this possibly being the source of the issue.  

The other issue related to two subtly incompatible types relating to the same underlying library with the same name appearing to represent the same concept, buried in layers of types derived from them.  

The display inconsistency bug, however, produced a more visible but less significant difference.  It appears to be in TypeScript, and can be simply and easily demonstrated. Fixing it could lead others to avoid fruitless hours of their own.  

This was originally observed in VSCode 1.71.0 but reproduces in the workbench.

### 🙂 Expected behavior
The typing tooltip shown on hover is the same in both settings.  With the initial issue report, I don't take a position on which one is more correct or otherwise better (I note that in 4.6.4, both versions include `| undefined`), but the inconsistency is problematic.