AdonisJS API
    Preparing search index...

    Type Alias ExtractTransformerVariants<Transformer>

    ExtractTransformerVariants: Exclude<
        keyof Transformer & string,
        keyof BaseTransformer<any>,
    >

    Extracts the variant methods of a transformer class. Any method that returns ResourceData or Promise can be picked for serialization.

    This utility type filters all methods of a transformer class to only include those that return the correct data types for resource serialization.

    Type Parameters

    • Transformer

      The transformer class to extract variant methods from

      class UserResource {
      toObject() { return { id: 1, name: "John" } }
      toSummary() { return { id: 1 } }
      invalidMethod() { return "not resource data" }
      }

      type Variants = ExtractTransformerVariants<UserResource> // "toObject" | "toSummary"