AdonisJS API
    Preparing search index...

    Type Alias InferData<Transformer, Variant, MaxDepth, Depth>

    InferData: Transformer extends { [K in Variant]: (...args: any[]) => unknown }
        ? UnpackValues<
            Awaited<ReturnType<Transformer[Variant]>>,
            MaxDepth,
            Depth,
        >
        : never

    Infers the serialized data structure of a transformer by extracting the return type of a specific variant method and unpacking it recursively.

    This is the primary type used to extract the TypeScript type of a transformer's output.

    Type Parameters

    • Transformer

      The transformer class to infer data from

    • Variant extends string = "toObject"

      The variant method name to use (defaults to 'toObject')

    • MaxDepth extends number = -1

      Maximum depth allowed for unpacking (defaults to -1 for unlimited)

    • Depth extends number = 0

      Current depth level (defaults to 0)

      class UserTransformer extends BaseTransformer<User> {
      toObject() {
      return {
      id: this.resource.id,
      name: this.resource.name,
      posts: PostTransformer.transform(this.resource.posts)
      }
      }
      }

      type UserData = InferData<UserTransformer>
      // Result: { id: number; name: string; posts: PostData[] }