Microsoft/TypeScript
GitHub ã§èŠãOnly `null` and `undefined` included in later overloads during inference between overloads
Open
#47,586 opened on 2022幎1æ25æ¥
Help WantedNeeds Investigation
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
overload null undefined
ð Version & Regression Information
- This is the behavior in every version I tried, and I wrote the FAQ
⯠Playground Link
Playground link with relevant code
ð» Code
This is a bit over-reduced but it's still weird
declare function callIt<T>(func: {
(): T;
(): T;
}): T;
declare function overloaded(): string;
declare function overloaded(): number | null;
// m: string | null. Where'd number go?
const m = callIt(overloaded);
ð Actual behavior
m: string | null
ð Expected behavior
m: string | number | null
This feels intentional since it only null and undefined make it out of the second signature, but I can't find where we do this or what the motivation behind it is.