Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

pug v-if not guarded as defined / != null #2329

Closed
Shinigami92 opened this issue Jan 20, 2023 · 10 comments
Closed

pug v-if not guarded as defined / != null #2329

Shinigami92 opened this issue Jan 20, 2023 · 10 comments
Labels
question Further information is requested

Comments

@Shinigami92
Copy link
Collaborator

I have a weird bug 馃

image

I have a component and use v-if="panel" for checking if the variable is not null
But in the @click it is still nullable, but this will never be null there

@rchl
Copy link
Collaborator

rchl commented Jan 20, 2023

It can be null because that code will run when clicking the element so at that point panel might have become null.

@Shinigami92
Copy link
Collaborator Author

@rchl
How am I possible to click on the button when the panel is null?

@rchl
Copy link
Collaborator

rchl commented Jan 20, 2023

That's true, the element will disappear then. I suppose that's not something the type system is aware of though so it might be hard to fix, if possible at all. Also there might be an issue like that already.

@Shinigami92
Copy link
Collaborator Author

As far as I know in a much historical previous version of volar this was working and didn't complain
Then later on @johnsoncodehk started to implemented more and more type heavier commits to volar
So I assume it is somehow possible to fix it at least in the context when the variable is on the same tag/component

@johnsoncodehk
Copy link
Member

We used to support it in 0.21.6, then removed it in 0.21.14, so it caused some wrong type behavior.
Later 0.34.12 supports it in another way, in the latest version you need to set vueCompilerOptions.narrowingTypesInInlineHandlers = true in tsconfig to enable it.

@johnsoncodehk johnsoncodehk added the question Further information is requested label Jan 23, 2023
@Shinigami92
Copy link
Collaborator Author

@johnsoncodehk I hope I just did not missed it but I feel like you need to setup a documentation (Maybe even with VitePress like other Vue-Ecosystem tools)

@johnsoncodehk
Copy link
Member

Yes we plan to document it at https://vuejs.org/.

@Shinigami92
Copy link
Collaborator Author

Just as a user feedback:
image

this is the place/link where I would usually look for a docs link

@johnsoncodehk
Copy link
Member

Good idea. :)

@EmilyRagan
Copy link

EmilyRagan commented Mar 1, 2024

Yes we plan to document it at https://vuejs.org/.

@johnsoncodehk I see in my tsconfig when setting this value that narrowingTypesInInlineHandlers is now deprecated, but I am still getting errors of the original problem reported in this issue. How can I resolve this? I have Vue 3.3.4 and vue-tsc 1.8.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants