arktypea
arktype9mo ago
McKamyk

spread and generics

I'm wanting to define a generic, then another generic wrapping and passing through the generic

const apiResponse = type('<t>', {
  data: 't',
  last_updated: 'number',
})
type ApiResponse<T> = ReturnType<typeof apiResponse.infer<T>>['infer']
// ^ this works fine

const apiPaginatedResponse = type('<t>', {
  '...': apiResponse<t>, // <-- what do I do here?
  cursor: 'null | string'
})
type ApiPaginatedResponse<T> = ReturnType<typeof apiPaginatedResponse.infer<T>>['infer']
Was this page helpful?