arktype
arktype copied to clipboard
Morph intersection in chained object inferred as never
This is a likely candidate for a bug in TS, though more investigation is needed. The b key following expression is incorrectly inferred as never:
const myType = type({
a: ["string", "=>", (s) => s.length],
}).and({
// this leads to b in the final type being inferred as never
b: [{ b: "boolean" }, "=>", (b) => b],
});
// if the type is defined separately, the inference works,
// meaning the bug is likely in TS
const b = type({ b: "boolean" }, "=>", (b) => b);
// final type is correctly inferred here
const myType = type({
a: ["string", "=>", (s) => s.length],
}).and({
b,
});