injections(vue): inject typescript instead of js (#5577)

Interpolations (`{{valid js code}}`) and directive attributes
(`<element :directive="valid js code"`) can also be typescript code,
hence we can inject typescript instead of javascript here and still
be ok with highlights (bar some syntax differences between ts and js)
This commit is contained in:
Pham Huy Hoang 2023-11-06 11:04:13 +09:00 committed by GitHub
parent a82bba45fb
commit 80f66cdef1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -57,12 +57,12 @@
((interpolation
(raw_text) @injection.content)
(#set! injection.language "javascript"))
(#set! injection.language "typescript"))
(directive_attribute
(quoted_attribute_value
(attribute_value) @injection.content
(#set! injection.language "javascript")))
(#set! injection.language "typescript")))
(template_element
(start_tag

View file

@ -1,12 +1,12 @@
<template>
<span>{{"Text inside interpolation"}}</span>
<!-- ^ javascript -->
<!-- ^ typescript -->
<template lang="pug"> a(:href="url") some link title in pug: </template>
<!-- ^ pug -->
<template v-if="'text inside directives'"></template>
<!-- ^ javascript -->
<!-- ^ typescript -->
</template>
<script> const foo = "1" </script>
<!-- ^ javascript -->