Microsoft/TypeScript
Voir sur GitHubType loosening regression with union types in TS 4.2
Open
#43 185 ouverte le 10 mars 2021
BugDomain: check: Type InferenceHelp Wanted
Métriques du dépôt
- Stars
- (48 455 stars)
- Métriques de merge PR
- (Merge moyen 6j 17h) (9 PRs mergées en 30 j)
Description
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