arktype
arktype copied to clipboard
Investigate inference for inlined type definitions
// Very efficient
const a = type({
a: "string",
});
// Also fine
const referenced = type("string");
const b = type({
a: referenced,
});
// Much slower
const b = type({
a: type("string"),
});
The problem seems to have to do with the way the inner type definition is validated. It should be independent of the outer type call, but somehow TS is correlating them- maybe validating twice?
It seems likely based on the nature of this issue that it is something that would need to be optimized from within TypeScript itself as opposed to within ArkType.