Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plus sign for number literals does not work. #2113

Open
harrison-munitz opened this issue May 16, 2024 · 0 comments
Open

Plus sign for number literals does not work. #2113

harrison-munitz opened this issue May 16, 2024 · 0 comments

Comments

@harrison-munitz
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant