Repository navigation
3.4 is here, with 6 features and 61 fixes since 3.3.14. Its headline is a new kind of syntax highlighting. This page shows that and the other parts you will notice. The full list of changes is at the end.
Highlighting that parses instead of guessing
This is the biggest change in 3.4, and you may only notice it when something that always looked slightly wrong now looks right.
Look at v-if="var as XXX" above. In 3.3 the closing quote and the tag after it turn red, and in some cases the following lines lose their colors too. Nothing is wrong with that code. The old grammar simply lost track of where the expression ended.
That is what a TextMate grammar normally is: a pile of regular expressions that guess at structure. The Vue grammar was written that way, by hand, for years.
It is now a recursive-descent TextMate grammar, generated by Monogram from a single grammar definition. That definition is run as a parser first, and the highlighter is derived from it, so the colors follow the structure Vue actually reads.
What that did for .vue files:
- Of the 154 files in our highlighting test suite, 65 are highlighted better and none worse.
- All 23 highlighting issues reported against the old grammar now pass.
- Of the 64 attribute forms Vue accepts, 63 are read the way Vue reads them. The old grammar managed 58.
Two more, each in a dark and a light theme:
v-pre content is not compiled, and now it is not colored as if it were.
Before
Now
{{ }} in a Markdown code block is code, not an interpolation.
Before
Now
If you maintain a theme or load the Vue grammar files by path, some scope names and file names changed. They are listed in the pull request.
Rich hover, redesigned
Rich hover arrived in 3.2 as an experimental table of a component's props, events and slots. In 3.4 the table has a new layout. A summary line comes first. Each prop shows its type and its default, with the description underneath, rendered as Markdown. Required props are listed first, deprecated ones are struck through.
It is still opt-in. Turn it on with the vue.hover.rich setting.
And not only in VS Code
Until now this hover was an HTML table, which most editors cannot display. The language server now looks at what your editor supports and picks a format it can show. In Neovim and other editors without HTML, the same information arrives as TypeScript interfaces with JSDoc comments.
Colors in Restricted Mode
VS Code now opens every new folder in Restricted Mode. Until this release the extension was switched off there, and a .vue file was a wall of plain text.
Syntax highlighting now works before you trust the workspace. The language server still waits for your trust, and starts without a restart once you give it.
Tell the checker what v-model binds
A v-model without an argument is checked against modelValue. For custom elements and some component libraries that is the wrong prop. vModelPropName names the right one for each tag, or false for none.
For a single file, put a comment at the top of the SFC.
<!-- @vModelPropName { "my-input": false } -->experimentalModelPropName is deprecated in favour of this option.
Incremental builds you can trust
vue-tsc --incremental and vue-tsc -b used to reuse build info written by another version of vue-tsc, or with different vueCompilerOptions. After an upgrade you kept seeing the old result until you deleted the build info file by hand.
Build info is now thrown away when the vue-tsc version or the options change, the same way it already was after a TypeScript upgrade.
All changes
language-core
- feat: add vModelPropName, deprecate experimentalModelPropName (9f588bf)
- fix: separate script block content without trailing newline (d845257)
- fix: type valueless directive binding value as undefined (6cd63e3)
- fix: resolve camelCase listeners of hyphenated emits (ee962ef)
- fix: strip the slot parameter wrapper when its tail is split (31e5f34)
- fix: emit the inference-only props copy as written (b77bba3)
- fix: type narrowed template bindings by declaration, not by assertion (16cc6fb)
- fix: keep a JSDoc
@importof<script setup>at module scope beside<script>(85bc68f) - fix: keep an import after a statement of
<script setup>at module scope (85bc68f) - fix: annotate the props parameter of a defineModel default through an alias (85bc68f)
- fix: include the models of a component with a runtime defineProps argument at target 3.6 (85bc68f)
- fix: keep the type aliases of JS components out of their declarations (85bc68f)
- fix: give the props that have defaults to the runtime props option of a component (85bc68f)
- fix: read the template's bindings in v-slot parameter types (85bc68f)
- fix: resolve the directives option by the keys Vue searches (85bc68f)
- fix: do not report htmlAttributes on components as unknown props (85bc68f)
- fix: link the listeners of a declared event prop to the prop (85bc68f)
- fix: map no code to the tag of an element that the source does not write (85bc68f)
- fix: annotate the props parameter in the copy of a defineModel default (85bc68f)
- fix: link template directives to their declarations (93d2ea6)
- fix: keep the setter type of a ref that the template narrows in a union with a non-ref (e889b7e)
- fix: give the setup result of a generic component a type alias (8780186)
- fix: generate a valid listener for an empty event expression (e80a989)
- fix: keep runtime emits when combined with defineModel (09cb67d)
- fix: omit declared props from inherited attrs of generic components (db16754)
- fix: declare the CSS modules type outside the template function (83757a5)
- fix: inline element types of template refs in emitted declarations (302c3ef)
- fix: keep
defineModeldefault factories valid with a model type or bare parameter (6a1ebbe) - fix: preserve component prop expressions during inference (dd13e6e)
- fix: keep generic functions passed to props from fixing component type parameters (5bed9c2)
- fix: generate valid JavaScript template-ref hoists (9c359ce)
- fix: resolve generic constraints of setup bindings read in
v-bind(cf1b1fa) - fix: keep completion on template token boundaries (077e834)
- fix: ignore the diagnostics of the fallthrough props copy instead of mapping them (cf904a1)
- fix: read the props of a
defineModeldefault through a function (bf03663) - fix: do not report TS4111 for slot names and tags under noPropertyAccessFromIndexSignature (32f2072)
- fix: type-check native .prop bindings against DOM types (4adac72)
- fix: accept overrides of the props a fallthrough root sets, and keep a declared prop's type (3f22efc)
- fix: construct only the constructable members of a component (f8ede47)
- fix: drop empty SFC blocks as @vue/compiler-sfc does (9913cf5)
- fix: check the template of a component with an
exposeoption against its internal instance (250d0a2) - fix: let a tsconfig override the
strictTemplatesit extends (091dc9f) - fix: apply the
vueCompilerOptionsof anextendsarray in order (b1b3a4b)
language-plugin-pug
- fix: map a class literal value to the literal (85bc68f)
- fix: read attribute values from code with CRLF line ends (85bc68f)
- fix: map the end of a self-closing element to the end of its pug start tag (85bc68f)
- fix: type-check a mixin body where it is called (4011ab8)
language-service
- feat: choose the component hover format from the client's capabilities (f103b32)
- feat: redesign the component hover table (3cb51bf)
- fix: place components option edit of document drop in script block (d337e2d)
- fix: skip document drop into an SFC without script (85bc68f)
- fix: suggest define assignments only in script setup (85bc68f)
- fix: insert a dropped or extracted component into the Options API components without reprinting them (85bc68f)
- fix: escape types, defaults and names in the component hover table (4466271)
- fix: resolve template auto-import items against their own document (970f69e)
component-meta
- fix: give the returned expression of a single-return block default (85bc68f)
- fix: find the defaults of quoted prop names (85bc68f)
tsc
- fix: discard incremental build info after a vue-tsc upgrade or vueCompilerOptions change (ea60968)
typescript-plugin
- fix: capitalize component name in import completions (ff898ef)
- fix: do not insert
.valueafter a ref that the template reads unwrapped (d736046)
vscode
- feat: derive the Vue TextMate grammars with Monogram (537381d)
- feat: support syntax highlighting in Restricted Mode (1b6088c)
- feat: redesign the welcome page (5a963c9)
- fix: keep Vue directives out of script and style blocks in pug (edbec72)
- fix: cache the reactivity analysis language service per project (ca36a14)
- fix: skip hot-swap when TypeScript exports are getter-only (a77b650)
- fix: highlight directive modifiers and slot names as Vue reads them (805cf0d)
Contributors: @johnsoncodehk, @lazerg, @serkodev, @ondrhn, @ValentinYoushkevich, @darkbasic, @zcf0508, @thelastbackspace, @og-orca, @officialasishkumar, @mkantautas, @jak-ch-ll, @jack-worman, @fazulk, @danielroe, @alecgibson, @akzarma, @Skandesh, @MFA-G, @EnesKartal, @CEXpp


