arktype icon indicating copy to clipboard operation
arktype copied to clipboard

Investigate inference for inlined type definitions

Open ssalbdivad opened this issue 1 year ago • 1 comments

// 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.

ssalbdivad avatar Jun 06 '23 22:06 ssalbdivad