question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: new value for the preserveParens option

See original GitHub issue

Would be good to have a mode in which ParenthesizedExpression nodes would be created only for parentheses used for JSDoc type assertions.

The syntax of JSDoc type assertions is simple: @type {...} JSDoc comment followed by a parenthesized expression. Anything else is not a type assertion. Reference: Closure Compiler, TypeScript.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thorn0commented, Mar 6, 2021

I am not sure if recursive type casting is possible

Yes, possible. Also they can be nested directly (people really use this):

/** @type MyType */ (/** @type any */ (x))

What’s the use case for this? And why do you want to turn off ParenthesizedExpression ? It’s in the spec

If you mean ESTree, ParenthesizedExpression is not there. It’s a non-standard extension. Overall, ESTree’s approach is to ignore insignificant parentheses. However, the JSDoc convention that uses such parentheses is widespread and important. So from the point of view of tools like formatters and linters, it makes sense to create these non-standard nodes only for JSDoc. In other cases, they only get in the way. E.g. Prettier doesn’t simply print the AST. It also does a lot of checks of the AST structure along the way to choose between different ways to print things. Taking ParenthesizedExpression nodes into account in all those checks would ridiculously complicate them, so actually what happens now in Prettier is an extra step that removes all ParenthesizedExpressions that aren’t JSDoc type assertions from the AST before passing it to printing.

Name it thorn

I sincerely believe something like PreserveJsdocParens would be a slightly better name. 😆

1reaction
3cpcommented, Mar 5, 2021

I see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · meriyah/meriyah - GitHub
context masks turns into negative value ... Feature request: new value for the preserveParens option enhancement New ... Feature: syntax check only mode....
Read more >
Feature Requests: What are they and how to manage them
These sorts of requests come about when end-users are seeking more value out of your product or have identified a new problem that...
Read more >
How To Manage Feature Requests [Template included]
This guide will teach you everything about feature requests – how to process them, manage them, respond to them, prioritize them – so...
Read more >
How to say no to product feature requests - Canny Blog
Here's how to say no to feature requests the right way. ... Many companies make it clear that they value user feedback. ......
Read more >
10 Tips for Responding Graciously to Customer Feature ...
Do you notice that you get many “bad” satisfaction tickets when customers are requesting product changes or new features? Picture this scenario: A....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found