-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFix AvailableA PR has been opened for this issueA PR has been opened for this issueWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Milestone
Description
Bug Report
When attempting to put together some conditional types to extract information about branded types, TS 4.2 is no longer able to correctly infer your intent.
type Branded<T, A> = A & { __brand: T }
type BrandedValue<A> = A extends Branded<unknown, infer R> ? R : never
// Expected to be 'string' but is 'string & { __brand: T }' in 4.2+
type T1 = BrandedValue< Branded< 'GUID', string > >
🔎 Search Terms
- Branded Types
- Conditional Types
- TypeScript 4.2
🕗 Version & Regression Information
- This changed between versions 4.1.5 and 4.2 beta
⏯ Playground Link
Working example in 4.1.5
🙁 Actual behavior
The brand is not removed from the return type
🙂 Expected behavior
The brand should be removed from the return type
whzx5byb, SlurpTheo and varkadov
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFix AvailableA PR has been opened for this issueA PR has been opened for this issueWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug