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

TypeScript: Fix missing comments in MethodDefinition #9872

Merged
merged 8 commits into from Dec 15, 2020

Conversation

fisker
Copy link
Sponsor Member

@fisker fisker commented Dec 11, 2020

Description

This comments is missing because ts parser have a node called TSEmptyBodyFunctionExpression, comment is attached as dangling comment in it, this type didn't go through print function, so I add an extra check here to prevent other unexpected cases.

I was going to print this comment in TSEmptyBodyFunctionExpression, but because babel-ts don't have this Node, so the comment is attached to the Identifier, If I print the comment in TSEmptyBodyFunctionExpression it will be inconsistent with babel-ts parser, so I marked it as "can't attach comments".

To fix #9324, we only need marked it as "can't attach comments", but I think better pass node through "print" except FunctionExpression.

Fixes #9324

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker fisker marked this pull request as ready for review December 11, 2020 09:46
@sosukesuzuki sosukesuzuki self-requested a review December 13, 2020 18:52
@fisker fisker merged commit 099ba04 into prettier:master Dec 15, 2020
@fisker fisker deleted the issue-9324 branch December 15, 2020 04:23
@fisker fisker mentioned this pull request Apr 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript: "comment not printed" between MethodDefinition and its semicolon
3 participants