Type 'distillOut<T>' is not assignable to type 'T'.
This produces error:
If I cast, then it works:
Why is the casting necessary? Shouldn't it be type
T after checking it's not type.errors?Type 'distillOut<T>' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'distillOut<T>'.Ttype.errorsimport { type, Type } from "arktype";
const test = <T>(validator: Type<T>): T => {
const result = validator({});
if (result instanceof type.errors) throw new Error();
return result;
}import { type, Type } from "arktype";
const test = <T>(validator: Type<T>): T => {
const result = validator({});
if (result instanceof type.errors) throw new Error();
return result as T;
}