devtypes - v2.0.0
    Preparing search index...

    Type Alias IsJSONSerializableStrict<T>

    IsJSONSerializableStrict: [T] extends [(...args: any[]) => any]
        ? false
        : [T] extends [bigint | symbol | undefined]
            ? false
            : [T] extends [string | number | boolean | null]
                ? true
                : [T] extends [readonly (infer U)[]]
                    ? [IsJSONSerializableStrict<U>] extends [true] ? true : false
                    : [T] extends [object]
                        ? IsTypeRecursive<T> extends true
                            ? false
                            : false extends {
                                [K in keyof T]: IsJSONSerializableStrict<(...)[(...)]>
                            }[keyof T]
                                ? false
                                : true
                        : false

    Type guard: strictly detect whether a type is JSON serializable.

    Type Parameters

    • T

      Type to test

    Recursively inspects the structure of T to ensure all components are fully compatible with JSON serialization rules.

    Strict check: functions and undefined are considered non-serializable.

    Will refuse any recursive type to ensure no cyclic references in objects.

    type A = IsJSONSerializableStrict< { a: string; b: number[] } >;   // true
    type B = IsJSONSerializableStrict< { a: string; b: undefined } >; // false
    type C = IsJSONSerializableStrict< ()=>void >; // false
    type D = IsJSONSerializableStrict< ( string | undefined )[] >; // false
    type Recurse = { direct: Recurse, union: number | Recurse }
    type E = IsJSONSerializableStrict< Recurse >; // false