vuejs / vetur

Vue tooling for VS Code.
https://vuejs.github.io/vetur/
MIT License
5.75k stars 594 forks source link

`instanceof` & `typeof` inside templates break syntax highlighting for the rest of the file #1854

Open WofWca opened 4 years ago

WofWca commented 4 years ago

Info

Problem

Using instanceof inside templates breaks syntax highlighting.

image

Reproducible Case

<template>
  <p v-show="p instanceof Array"></p>
</template>
JoelFeiner commented 4 years ago

A good and reasonable workaround would be to use a computed property instead, rather than have interesting logic inside the template.

toshiya14 commented 4 years ago

I am facing the same issue, and I found an resolution is below:

<span v-if="!!(item.createdTime instanceof Date)"></span>

I think this would help you before the issue is fixed.

Eternal-Rise commented 3 years ago

same issue with typeof

liplum commented 1 year ago

I can reproduce this in Volar too. My solution is to wrap the expression with parentheses.

<template v-if="(file instanceof LocalFile)">