Microsoft/TypeScript
GitHub ã§èŠãType loosening regression with union types in TS 4.2
Open
#43,185 opened on 2021幎3æ10æ¥
BugDomain: check: Type InferenceHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
- union type
ð Version & Regression Information
- bug exists in 4.2
- works in 4.1
⯠Playground Link
When using union types with helper function constructing one of the type, the type is incorrectly loosened from string value type to string (func1). Directly returning the shape (func2) or using as const (func3) fixes it. Also when simplifying and removing the union (func4), it starts working.
This was not problem in 4.1, errors only in 4.2