'is this type notation in the Vue decorator constructor correct?

I used Vue decorator notation like this:

@Prop({ type: Object || null, default: null })

in Vue documentation I saw notation by array:

@Prop({ type: [ Object, null ], default: null })

but does the notation through the sign || is that wrong?



Solution 1:[1]

You can use it like so, but it's not the right way.

See Logical OR (||). If you set null || Object you will get Object, because Boolean(null) is false. In your variation you will get Object because Boolean(Object) is true. But you can use it like this:

@Prop({ type: Object, default: null })

Not only in an array way ([Object]).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oybek Odilov