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

Allow parentheses when JSDoc to allow intellisense #14227

Closed
EloB opened this issue Jan 24, 2023 · 5 comments · Fixed by #14262
Closed

Allow parentheses when JSDoc to allow intellisense #14227

EloB opened this issue Jan 24, 2023 · 5 comments · Fixed by #14262
Assignees
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken type:typechecking Issues and PRs related to using TypeScript's JSDoc syntax to typecheck the codebase

Comments

@EloB
Copy link

EloB commented Jan 24, 2023

Prettier 2.8.3
Playground link

--parser babel

Input:

module.exports = /** @satisfies {Record<string, string>} */ ({
  hello: 1337,
});

Output:

module.exports = /** @satisfies {Record<string, string>} */ {
  hello: 1337,
};

Expected behavior:
Keep those parentheses to not break intellisense.

module.exports = /** @satisfies {Record<string, string>} */ ({
  hello: 1337,
});

Here is an example of using @satisfies jsdoc. microsoft/TypeScript#51753

prettier

@kachkaev kachkaev added status:needs discussion Issues needing discussion and a decision to be made before action can be taken lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:typechecking Issues and PRs related to using TypeScript's JSDoc syntax to typecheck the codebase labels Jan 24, 2023
@EloB
Copy link
Author

EloB commented Jan 24, 2023

It becomes more and more popular to include JSDoc for configs etc. It really improves developer experience to not have to jump into documentation pages for property names and also prevents typos.

Here is for instance Next.js official documentation.
https://nextjs.org/docs/api-reference/next.config.js/introduction

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  /* config options here */
}

module.exports = nextConfig

At the moment I have to disable prettier because it removes those parentheses so I wasn't able to use @satisfies JSDoc when I had prettier running.

@type and @satisfies have different use cases. So it's sad if Prettier prevents us from using it.

@EloB
Copy link
Author

EloB commented Jan 30, 2023

How do we start a discussion or get some traction on this? What alternatives do we have?

I really want to continue use Prettier it's amazing! I also want to use best practices with JSDoc. Especially when it improves intellisense.

I have no experience with the Prettier team or this codebase. I only have love for what you guys created.

Is there something that I can help with? I don't know how your process work... :)

@fisker fisker self-assigned this Jan 30, 2023
@fisker
Copy link
Sponsor Member

fisker commented Jan 30, 2023

@fisker
Copy link
Sponsor Member

fisker commented Jan 30, 2023

#14262

@EloB
Copy link
Author

EloB commented Feb 7, 2023

@fisker haven’t tried it yet but you are amazing!

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken type:typechecking Issues and PRs related to using TypeScript's JSDoc syntax to typecheck the codebase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants