locked
Type.Union Returns Any for Non-Nullable Types RRS feed

  • Question

  • Hello,

    I’ve been playing with Type.Union, which is described as “Returns the union of a list of types.” How this method unions between different types that do not allow null is puzzling me. :-)

    Type.Union({type number, type text}) // type any

    Why is any returned here instead of anynonnull? It seems like anynonnull would be the most derived nullable primitive type that the two types can be unioned into.

    A possible hypothesis is that maybe Type.Union falls back to returning any anytime it is asked to union different types together. However, this is disproved by the fact that Type.Union({type number, type null}) returns nullable number, not any.

    Does anyone have any ideas about this?

    Thank you,
    Ben

    Wednesday, January 29, 2020 8:53 PM

Answers

  • Hi Ben. This behavior is arguably a bug, but it's been there since the beginning of time (or at least the early days of PQ) as far as we can tell, and isn't likely something we'll be changing any time soon.

    Ehren

    Tuesday, February 4, 2020 12:09 AM

All replies

  • Hi Ben. This behavior is arguably a bug, but it's been there since the beginning of time (or at least the early days of PQ) as far as we can tell, and isn't likely something we'll be changing any time soon.

    Ehren

    Tuesday, February 4, 2020 12:09 AM
  • Thanks, Ehren!
    Tuesday, February 4, 2020 3:11 PM