Skip to content

Conversation

auvred
Copy link
Contributor

@auvred auvred commented Jul 9, 2023

Description

Closes #14864

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

Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

textToDoc,
{
parser: "babel-ts",
__isVueScriptGeneric: true,
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should use a better name for this flag? Plugins like prettier-plugin-pug may use it in future, we'll not able to change it.

Copy link
Contributor Author

@auvred auvred Jul 10, 2023

Choose a reason for hiding this comment

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

Sounds good, something like __isEmbeddedTypescriptGenericParameters?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed this change. Maybe then we should rename printVueScriptGenericAttributeValue? Because it doesn't contain vue-specific logic. And I guess if somebody in future will use __isEmbeddedTypescriptGenericParameters, he probably will be required to duplicate at least this statement

return formatAttributeValue(
  `type T<${value}> = any`,
  textToDoc,
  {
    parser: "babel-ts",
    __isEmbeddedTypescriptGenericParameters: true,
  },
  shouldHugJsExpression,
);

Copy link
Member

Choose a reason for hiding this comment

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

This file is internal, we can rename it anytime we want, but I'll be fine if you want to rename it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, if we can rename it after, this is fine! Let's leave it as it is. If I need to fix anything else, let me know :)

Copy link
Member

@sosukesuzuki sosukesuzuki left a comment

Choose a reason for hiding this comment

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

One changelog comment

@@ -0,0 +1,24 @@
#### Add support for Vue "Generic Components" (#15066 by @auvred)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@sosukesuzuki sosukesuzuki merged commit 7485c45 into prettier:main Jul 16, 2023
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

Successfully merging this pull request may close these issues.

Support Vue "Generic Components"
4 participants