-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Labels
lang:flowIssues affecting Flow-specific constructs (not general JS issues)Issues affecting Flow-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 2.8.8
Playground link - Not supported, Flow parser too old
Input:
type T<U> = 'a' | ('b' extends U ? 'c' : empty);
Output:
type T<U> = 'a' | 'b' extends U ? 'c' : empty;
Expected output:
type T<U> = 'a' | ('b' extends U ? 'c' : empty);
Why?
Removing the parens changes the Flow type:
// Option 1:
type T1<U> = ('a' | 'b') extends U ? 'c' : empty;
// T1<'a' | 'b'> -> 'c'
// T1<'a'> -> empty
// T1<'b'> -> empty
// Option 2:
type T2<U> = 'a' | ('b' extends U ? 'c' : empty);
// T2<'a' | 'b'> -> 'a' | 'c'
// T2<'a'> -> 'a'
// T2<'b'> -> 'c'
// Both get Prettier'd to:
type T3<U> = 'a' | 'b' extends U ? 'c' : empty;
// which is equivalent to Option 1
Metadata
Metadata
Assignees
Labels
lang:flowIssues affecting Flow-specific constructs (not general JS issues)Issues affecting Flow-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.