Skip to content

fix(content-mapper): report a Vue version below the minimum target - #6392

Open
ondrhn wants to merge 1 commit into
vuejs:feat/vue-content-mapperfrom
ondrhn:fix/issue-6391-content-mapper-report-a-vue
Open

ondrhn wants to merge 1 commit into
vuejs:feat/vue-content-mapperfrom
ondrhn:fix/issue-6391-content-mapper-report-a-vue

Conversation

@ondrhn

@ondrhn ondrhn commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

On a project that has Vue 3.2 installed, tsc --runExternalCode type-checks nothing in a template and exits 0. <img :src="obj" /> with an object obj is accepted, while the same file reports TS2322 once Vue is 3.5. Nothing points at the Vue version either, so the project looks checked when it is not.

Without a target option, CompilerOptionsResolver resolves it from node_modules/vue, and nothing validates the result against the 3.3 minimum that #6170 settled on. The generated code then references declarations that an older Vue does not have — vue/jsx-runtime for __VLS_intrinsics is the one that matters here — and because those errors sit in generated code that no source range maps back to, the host drops them; IntrinsicElements becomes an error type and every native element is any. toTargetDiagnostic in optionDiagnostics.ts now turns a resolved target below 3.3 into an optionDiagnostics entry, which openProject reports next to the option and plugin diagnostics it already returns. With Vue 3.2.47 installed the entry in the tsconfig gets error vue5: Vue 3.3 or later is required, but 'target' resolves to 3.2. and the compiler exits 2. This reports the unsupported version rather than restoring a codegen fallback for it, since b7d10ee22 dropped the pre-3.3 branches deliberately.

The files this touches are the ones #6390 moves, so it is kept to one helper and one call site.

fix #6391

`target` defaults to the installed Vue version, and the code generated for
a version below 3.3 references declarations such as `vue/jsx-runtime` that
Vue does not have. The host drops those errors because no source range maps
to them, so native elements lose their types without any diagnostic.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for tracking this down, the diagnosis of vue/jsx-runtime is right. Two changes before this can go in.

1. Drop the advice to set target. The message ends with "or set 'target' to the version the project runs". On the reproduction of #6391 (Vue 3.2.47) with this PR applied:

target result
not set error vue5: Vue 3.3 or later is required…, exit 2
3.3 no output, exit 0
3.5 no output, exit 0

So a user who follows the advice with any value that makes the error go away is back in the state the issue reports: nothing in the template is checked, and nothing says so. Please end the message at "Upgrade Vue." and reword the test comment "an older Vue that the option overrides is not reported", which reads as if that case were fine.

2. Correct the cause in the description and the doc comment. The host does not drop these errors. The mapper itself emits an ignore directive for every range of generated code that maps to no source (buildDiagnosticDirectives in lib/result/tsCodeMappings.ts), and the import('vue/jsx-runtime') specifier is in such a range.

That is also where the rest of this gets fixed, in a separate change on our side: once the specifier maps to the <template> tag, TypeScript reports TS2307: Cannot find module 'vue/jsx-runtime' in all three rows above, and for a lib other than vue, which the version check cannot see since target is always read from node_modules/vue. It is not ready yet: it also surfaces that the same import does not resolve in a JS component that has both <script> and <script setup>, which has to be sorted out first.

With that in place this PR is what turns "module not found" into "upgrade Vue" for the common case, so it is still worth having with the two changes above.

Posted for johnsoncodehk by this workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant