1 year ago

#83581

test-img

user2690527

How to document a nullable union type with jsDoc?

According to jsDoc - tag @type the correct way to annotate a union type is @type {(number|boolean)} and the correct way to annotate a nullable type is @type {?number}.

How do I document a type which is a union and nullable at the same time? I tried

  • @type {?(number|boolean)} -- question mark in front of parentheses
  • @type {(?number|?boolean)} -- mark every type of the union individually nullable
  • @type {(?number|boolean)} -- mark only the first type of the union nullable

However, my IDE (JetBrains PhpStorm) compains about every variant.

jsdoc3

0 Answers

Your Answer

Accepted video resources