-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
Bug Report
🔎 Search Terms
Conditional types, union types, literal types, boolean
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about generics, union types and booleans
⏯ Playground Link
Playground link with relevant code
💻 Code
type Test<T> = T extends never ? never[] : T[];
let x: Test<boolean> = [true, false];
let y: Test<3|4|5> = [5,3];🙁 Actual behavior
Compiles with errors
Type 'boolean[]' is not assignable to type 'false[] | true[]'.
Type 'boolean[]' is not assignable to type 'false[]'.
Type 'boolean' is not assignable to type 'false'.
Type '(3 | 5)[]' is not assignable to type '3[] | 4[] | 5[]'.
Type '(3 | 5)[]' is not assignable to type '3[]'.
Type '3 | 5' is not assignable to type '3'.
Type '5' is not assignable to type '3'.
x is of type true[] | false[]
y is of type 3[] | 4[] | 5[]
🙂 Expected behavior
x be of type boolean[]
y be of type (3|4|5)[]
Compiles with no errors
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code