arktypea
arktype9mo ago
knthmn

Type instantiation is excessively deep and possibly infinitely deep

Hello,

I have some TRPC endpoint definition which contain some complex type

type VeryComplexType = ... // (discriminated union of 40 options that comes from some library)

// error: Type instantiation is excessively deep and possibly infinitely deep
const FooPayload = type({
  bar: 'object' as type.cast<VeryComplexType>
})

const router = {
  get(): procedure().output(FooPayload).query(() => {...})
}


For this matter I am not even checking the schema of VeryComplexType, I just want to contain the type in the schema definition and get end-to-end type safety. Is there a way to work around the issue?
Was this page helpful?