-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow ignoring specific exposed setup vars with internal prefixes ("_" and "$") #4532
Comments
In practice, you should really import individual functions from lodash because of the size difference, but a compiler option would definitely help. |
You are not limited by this when using |
@yyx990803 - thanks, I am using script setup already. This issue has not been a blocker at all, it's just been filling my browser console with warnings. I was able to figure out how to hide it yesterday using a custom warning handler, but I still think another config setting as mentioned above could be helpful. For anyone else finding this - here is the warning handler:
@posva - yeah I'm aware. I personally find a single lodash import and calling
|
Hmm, I don't think this should happen with Do you have a reproduction? |
I found that in dev mode, if internal exposed
|
@ygj6 's PR should fix usage of |
Thanks so much! I just confirmed that @ygj6's bug report is more up to date than mine and seems to be the same thing - I reproduced his issue importing lodash rather than using a ref named (I'm still using a slightly older version of vue 3 due to volar + typescript not quite being up to date with the latest and greatest, last time I tried to update anyway...) |
What problem does this feature solve?
it would be great to be able to specify specific variables to disregard when showing this warning:
setup() return property "_" should not start with "$" or "_" which are reserved prefixes for Vue internals
Specifically I am using lodash, so I often have something like
import _ from 'lodash'
in my files.When using the options api, this isn't really a huge issue, because usually lodash functions aren't needed in the template, and renaming lodash itself or a specific function while explicitly exposing it to the template isn't too common. However with the new script setup API, this would mean having to always rename lodash itself when importing it. While that's fine, it's not great for readability when lodash being named
_
is the norm.What does the proposed API look like?
A few things come to mind that could help
_
itself from this warningapp.config.globalProperties
but something likeapp.config.allowInternalPrefixSetupProps = ['_', '_myVar', '$somethingSpecial']
The text was updated successfully, but these errors were encountered: