AdonisJS API
    Preparing search index...

    Type Alias SerializeJSONTypes<T>

    SerializeJSONTypes: T extends ForcefullyAllowedTypes
        ? T
        : T extends CanBeSerialized<infer A>
            ? SerializeJSONOwnTypes<A>
            : SerializeJSONOwnTypes<T>

    Main serialization type that handles objects with toJSON methods. If a type has a toJSON method, extracts and serializes the return type. Otherwise, serializes the type directly.

    Type Parameters

    • T

      The type to serialize

      class User {
      constructor(public id: number, public name: string) {}
      toJSON() {
      return { id: this.id, name: this.name }
      }
      }

      type SerializedUser = SerializeJSONTypes<User>
      // Result: { id: number; name: string }