Type 'distillOut<T>' is not assignable to type 'T'.
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;}
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;}
This produces error:
Type 'distillOut<T>' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'distillOut<T>'.
Type 'distillOut<T>' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'distillOut<T>'.
If I cast, then it works:
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;}
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;}
Why is the casting necessary? Shouldn't it be type