Type Alias InsideValues<Tinput>

InsideValues<Tinput>: Tinput extends undefined
    ? undefined
    : Tinput extends null
        ? null
        : Tinput extends ((...args: any[]) => infer FnReturn)
            ? FnReturn
            : Writable<Tinput> extends Generator<infer Item>
                ? Item
                : Writable<Tinput> extends AsyncGenerator<infer Item>
                    ? Item
                    : Writable<Tinput> extends Promise<any>
                        ? Awaited<Tinput>
                        : Writable<Tinput> extends (infer Element)[]
                            ? Element
                            : Writable<Tinput> extends TypedArrayBigInt
                                ? bigint
                                : Writable<Tinput> extends TypedArrayNumber
                                    ? number
                                    : Writable<(...)> extends ArrayBuffer
                                        ? number
                                        : (...) extends (...)
                                            ? (...)
                                            : (...)

InsideValues

Similar idea to TS's ReturnType, or GeneratorType, Awaited etc. InsideValues gets the "Return value" or "Nested Values" or "elements" (collectively "items") value types, that are nested inside Tinput:

Inside Values are different & similar for every type: it's the value they convey. For Function it's their ReturnType, for Promise it is Awaited (i.e Resolved value type), for Array its Array elements, and so on for TypedArray, Map, Set, Generator, Iterator, Iterable, Plain Objects, Instances, Classes and IArguments & even Singles!

It can be used on every values, not just IsNestingObject or IsInspectableNested, but also for most Tinputs that hold some other value (types) somehow.

So all types are allowed as Tinput: non-nested/non-Many types (i.e Single primitives like number, string, etc return the same type back, while their Boxed Primitives, return their primitive type.

In effect:

  • Functions return their return type (acts as ReturnType)
  • Generators, AsyncGenerators, Iterators, Iterable return their yielded types
  • Promises return their resolved type (acts as Awaited)
  • Arrays return their elements type
  • POJSOs and instances return the type of their prop's values
  • Classes return the type of their static prop's values. Note that it also always contain itself as a value.
  • Maps, Sets return their key or value type
  • TypedArrays return their element type
  • WeakMap, WeakSet return their value type
  • Boxed primitives return their primitive type
  • Errors return string (i.e their message)
  • All other Single types return themselves and finally
  • IArguments cant work, no type info - returns any @todo: why any and not itself?

Note: we use Writable instead of Tinput, to avoid readonly issues

Type Parameters

  • Tinput extends any