arktypea
arktype9mo ago
log1st

Issue with Default<> in Type as generic.

I'm trying to create a generic function that accepts type returns other type.

export const generic = <t = unknown, $ = {}>(filter: Type<t, $>) =>
  type({
    take: "number.integer = 10",
    filter: filter,
  });


But if I'm trying to pass something that contains defaultable type it throws error:

const example = generic(type({
  slug: `string = "defaultSlug"`
})); // It says Type Default<string, "defaultSlug"> is not assignable to type string


Looks like there's a problem in my usage of Type generic. Cause if I create type without generic function it works perfectly.
Was this page helpful?