Volar/vue-tsc no longer showing type errors in templates after v0.35.2
See original GitHub issueI’m experiencing an issue related to type checking in templates: VSCode/Volar correctly shows a type violation when trying to pass a variable of type SomethingNonFalsy | undefined
to a component’s prop that basically only accepts SomethingNonFalsy | null
:
Prop definition:
However, vue-tsc --noEmit
exits with code 0 and without showing any errors.
Now here’s the thing: The above happened with VSCodium 1.70.0, vue-tsc 0.40.1 and Volar 0.30.1.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Intermezzo BEGIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The latter was the most recent version of Volar (more specifically: johnsoncodehk.volar) that I could find in VSCodium:
My understanding is that the package johnsoncodehk.volar
has been renamed to vue.volar
and only the latter comes with more recent versions. But vue.volar
doesn’t show up in my search results in VSCodium?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Intermezzo END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Anyway, if I download Vue.volar-0.40.1@linux-x64.vsix
manually from the marketplace and install it in VSCodium by hand, the above type error disappears, i.e. the behavior of Volar then matches the (IMO wrong) behavior of vue-tsc 0.40.1. Could it therefore be that a bug has been introduced here in the repo between Volar/vue-tsc 0.30.1 and Volar/vue-tsc 0.40.1?
To double-check I rolled back to vue-tsc 0.30.1. Now, vue-tsc --noEmit
shows the same (correct) type error and, in fact, many other type errors in templates – not necessarily related to prop types – such as:
[…] error TS2345: Argument of type 'Maybe<string> | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
19 :disabled="disabledItems.includes(selectedItemId)"
~~~~~~~~~~~~~~
[…] error TS2533: Object is possibly 'null' or 'undefined'.
32 >{{ item.description }}</span
~~~~
(Background: Both selectedItemId
and item
can indeed be null
or undefined
, so these type errors are correct as well.)
PS: I also happened to have vue-tsc v0.35.2 lying around – that version, too, fails to recognize the type errors.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:6 (1 by maintainers)
@Alverrt @last-partizan @fi3ework Again, it looks like you might be facing a separate issue. The present ticket is about a bug that’s been occurring starting from at least v0.35.2. You seem to be talking about a bug that was introduced in v0.40.x? If so, would you mind opening a new ticket?
Hi @codethief, first thanks for the report, but I can’t reproduce it, could you try can it reproduce in https://github.com/johnsoncodehk/volar-starter?