@luolapeikko/ts-common
    Preparing search index...

    Type Alias OneOf<TypesArray, Res, AllProperties>

    OneOf: TypesArray extends [infer Head, ...(infer Rem)]
        ? OneOf<Rem, Res | OnlyFirst<Head, AllProperties>, AllProperties>
        : Res

    OneOf type to handle one of types (non-union way as union combines type).

    Type Parameters

    • TypesArray extends any[]

      The array of types to combine

    • Res = never

      The result type

    • AllProperties = MergeTypes<TypesArray>

      The union of all properties

    function test(data: OneOf<[{data1: string}, {data2: string}]>) {
    }

    v0.2.6