Vetur: Incorrect syntax highlighting when using nullish coalescing in template

Created on 12 Apr 2021  Â·  2Comments  Â·  Source: vuejs/vetur

  • [x] I have searched through existing issues
  • [x] I have read through docs
  • [x] I have read FAQ
  • [x] I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: Win10
  • Vetur version: 0.33.1
  • VS Code version: 1.55.1

Problem


When using nullish coalescing(??) in template, syntax highlighting behaves unexpectedly:

image

While using || the highlighing is correct:

image

I don't know why but this problem doesn't happen on my macOS (with same VSCode extensions and settings).

Reproducible Case

Create a new .vue file:

<template>
  <div>
    <span>
      {{ aVariable ?? 3 }}
    </span>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';

export default defineComponent({
  props: {
    aVariable: { type: Number, required: true },
  },
});
</script>
bug grammar

Most helpful comment

Similar happens when using typeof operator in a v-if condition

Using typeof
image

No typeof
image

All 2 comments

Similar happens when using typeof operator in a v-if condition

Using typeof
image

No typeof
image

A possible workaround for the typeof could be to add brackets:
image

image

Was this page helpful?
0 / 5 - 0 ratings