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

feat: Support for @vue-ignore, @vue-skip, @vue-expect-error directive comments #3215

Merged
merged 4 commits into from May 22, 2023

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented May 22, 2023

Close #2366

Support 3 directive comment syntax for template.

@vue-ignore: Similar to @ts-ignore, ignore errors of the next template node. (Not just the next line)
@vue-expect-error: Similar to @ts-expect-error, report if the next template node has no errors.
@vue-skip: The next template node and its child nodes will skip generating virtual code.

Usage

<template>
  <!-- @vue-ignore -->
  <HelloWorld :msg="wrongType" />

  <!-- @vue-expect-error -->
  <HelloWorld :msg="wrongType" />

  <!-- @vue-skip -->
  <SomethingYouDontWantVolarToRecognizeIt>
    ...
  </SomethingYouDontWantVolarToRecognizeIt>
</template>

@johnsoncodehk johnsoncodehk merged commit 92e5dc8 into master May 22, 2023
6 checks passed
@johnsoncodehk johnsoncodehk deleted the directiveComment branch May 22, 2023 00:42
@Anoesj
Copy link

Anoesj commented May 24, 2023

TypeScript uses @ts-expect-error, not @ts-expected-error. Other than that, great stuff! 😄

Copy link

@nekocom3745 nekocom3745 left a comment

Choose a reason for hiding this comment

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

packages/vue-language-core/src/generators/template.ts

Copy link

@nekocom3745 nekocom3745 left a comment

Choose a reason for hiding this comment

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

packages/vue-language-core/src/generators/template.ts

@johnsoncodehk
Copy link
Member Author

@Anoesj Unfortunately bug 🤦, will fix it in the next release, thanks for the report.

@johnsoncodehk
Copy link
Member Author

TypeScript uses @ts-expect-error, not @ts-expected-error.

Fixed by 5696eb2

@AlansCodeLog
Copy link

I tried this but having a v-if breaks it. I had to move the v-if into a template, then it works.

@saibotk
Copy link

saibotk commented Jun 14, 2023

What about allowing comments to follow the tags?

eg:

<!-- @vue-expect-error We could type this with some magic, but it would probably be complex to do -->

equivalent in ts:
// @ts-expect-error We could type this with some magic, but it would probably be complex to do

@jfrs
Copy link

jfrs commented Jun 16, 2023

  <!-- @vue-expected-error -->

I tried to copy/paste the examples and got caught by the expected typo, might be worth editing the snippet!

@wenfangdu
Copy link
Contributor

What about allowing comments to follow the tags?

eg:

<!-- @vue-expect-error We could type this with some magic, but it would probably be complex to do -->

equivalent in ts:
// @ts-expect-error We could type this with some magic, but it would probably be complex to do

@saibotk That's already supported in 1.8.0.

@johnsoncodehk johnsoncodehk changed the title feat: Support for @vue-ignore, @vue-skip, @vue-expected-error directive comments feat: Support for @vue-ignore, @vue-skip, @vue-expect-error directive comments Jun 17, 2023
johnsoncodehk added a commit that referenced this pull request Jul 5, 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.

Allow using @ts-expect-error in Vue templates
7 participants