effect
effect copied to clipboard
Incorrect Type Inference with unions of schemas
🐛 Bug report
Reproducible example
import * as S from '@effect/schema/Schema'
declare const s: S.Schema<string> | S.Schema<number>
const x: S.Schema<string | number, string | number> = s // error :)
const y = S.union(s) // no error :(
Current Behavior
Currently, const x generates a type error, correctly indicating the incompatibility between the union type and the expected type. However, const y does not generate any error, allowing the union to be used without any issues.
Expected behavior
The expected behavior is that both const x and const y should generate a type error since s is a union of S.Schema<string> and S.Schema<number>.
Your environment
| Software | Version(s) |
|---|---|
| @effect/schema | 0.20.1 |
| TypeScript | 5.x |