Sebastian Andil
Sebastian Andil
This has been brought up in Zod as well: https://github.com/colinhacks/zod/issues/1868
With this workaround, the types aren’t narrowed properly though
@fabian-hiller just tried it and indeed it’s a TS limitation... [Here is a reproduction](https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAhgEwQJwKYQjAvDA3gKBhgEsEAuGAcgEYAmAZkoBpCYAzY1AGwQGFwOAcwoEiRKAE8ADqgqVEKdBEqsAviyIA3OFwCusvKyLBikuXAgI2Koqvx38oSLDC6AttkNFSc+gBYAVgA2ZlYObj4BYmEvMUkZOVc3ACNUZBsYdVZtPQM6ent8fHjUGAAxTh5PEpA2eCQ0DBgAHxgauqSip2h2ME8ACnCeCgqIgEpY4jrByoQAOiHIsCE5kuwsHHkGpUoJ0TE0KF1kPsW5nP05k0kjGAB6O7En5+eAPQB+NXsgA)
I suppose there’s no difference between `v.variant` & `v.union` in this case, is there @fabian-hiller? The best thing to do here is just use type guards, I think
I’ve been thinking about it more lately, and I think implementing something like distributed union with a nested discriminant would be swimming against the tide. It doesn’t work in TypeScript...