You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JSDoc allows you to use literals, including numbers for type definitions, such as when a function only works on a certain domain: /** @param foo {(1|2|"banana")} */
However, unlike JS itself, it seems you are not allowed to include a plus sign + for these numbers, even if it might improve clarity:
Invalid: /** @param sign {(-1|+1)} */
Valid: /** @param sign {(-1|1)} */
I tested this in multiple different editors, including VSCode, PHPStorm (jetbrains), and CodeSandbox.io, each with their respective default configurations. All of them had problems with the plus sign, but the behavior varied from giving a syntax error and not showing the type hint at all to replacing the +1 with any.
The text was updated successfully, but these errors were encountered:
JSDoc allows you to use literals, including numbers for type definitions, such as when a function only works on a certain domain:
/** @param foo {(1|2|"banana")} */
However, unlike JS itself, it seems you are not allowed to include a plus sign
+
for these numbers, even if it might improve clarity:Invalid:
/** @param sign {(-1|+1)} */
Valid:
/** @param sign {(-1|1)} */
I tested this in multiple different editors, including VSCode, PHPStorm (jetbrains), and CodeSandbox.io, each with their respective default configurations. All of them had problems with the plus sign, but the behavior varied from giving a syntax error and not showing the type hint at all to replacing the
+1
withany
.The text was updated successfully, but these errors were encountered: