Skip to content

TypeScript: Print dangling comment in empty type parameters#7729

Merged
alexander-akait merged 6 commits into
prettier:nextfrom
sosukesuzuki:fix-7574
Mar 10, 2020
Merged

TypeScript: Print dangling comment in empty type parameters#7729
alexander-akait merged 6 commits into
prettier:nextfrom
sosukesuzuki:fix-7574

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Mar 8, 2020

Copy link
Copy Markdown
Contributor

Fixes #7574

// Input
const a: T</* comment */> = 1;

// Prettier stable
Error: Comment "comment" was not printed. Please report this error!
    at https://prettier.io/lib/standalone.js:15543:15
    at Array.forEach (<anonymous>)
    at ensureAllCommentsPrinted (https://prettier.io/lib/standalone.js:15541:17)
    at coreFormat (https://prettier.io/lib/standalone.js:15592:5)
    at format (https://prettier.io/lib/standalone.js:15832:75)
    at formatWithCursor (https://prettier.io/lib/standalone.js:15848:14)
    at https://prettier.io/lib/standalone.js:31794:17
    at Object.format (https://prettier.io/lib/standalone.js:31802:14)
    at formatCode (https://prettier.io/worker.js:234:21)
    at handleMessage (https://prettier.io/worker.js:185:18)

// Prettier master
const a: T</* comment */> = 1;
  • I’ve added tests to confirm my change works.
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/pr-XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@j-f1 j-f1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier pr-7729
Playground link

--parser typescript

Input:

const a: T<
  	// comment
  > = 1;

Output:

const a: T<// comment> = 1;

Comment thread changelog_unreleased/typescript/pr-7729.md Outdated
Comment thread src/language-js/printer-estree.js Outdated

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@alexander-akait alexander-akait merged commit f8692f3 into prettier:next Mar 10, 2020
@sosukesuzuki sosukesuzuki deleted the fix-7574 branch March 10, 2020 15:14
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 11, 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.

4 participants