Setting value of a field which is of type U to a value of type A, where A is a union case of U causes an error when A is refined.
Minimal example
import { set } from "shades";
type A = { type: "a" };
type B = { type: "b" };
type U = A | B;
type Test = {
union: U;
};
const t: Test = { union: { type: "a" } };
console.log(t);
console.log(set("union")(({ type: "b" }) as B)(t)); // Type 'A' is not assignable to type 'B'
Setting value of a field which is of type U to a value of type A, where A is a union case of U causes an error when A is refined.
Minimal example
https://codesandbox.io/s/divine-frost-3xe5b?file=/src/index.ts:0-254
I think an issue might be in how HasKey is used in the type definition
Here the type S is defined to be something that has a key with value of type V, whereas I think it should be of some kind of supertype of V.
I've tried with
but that removes error even for incorrect types.