vetur icon indicating copy to clipboard operation
vetur copied to clipboard

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

Open WofWca opened this issue 4 years ago • 4 comments

  • [x] I have searched through existing issues
  • [x] I have read through docs
  • [x] I have read FAQ

Info

  • Platform: Win
  • Vetur version: 0.24.0
  • VS Code version: 1.44.1

Problem

Using instanceof inside templates breaks syntax highlighting.

image

Reproducible Case

<template>
  <p v-show="p instanceof Array"></p>
</template>

WofWca avatar Apr 16 '20 08:04 WofWca

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

JoelFeiner avatar Apr 17 '20 16:04 JoelFeiner

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.

toshiya14 avatar Oct 27 '20 07:10 toshiya14

same issue with typeof

Eternal-Rise avatar Jun 12 '21 09:06 Eternal-Rise

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

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

liplum avatar Apr 10 '23 18:04 liplum