jshmrtn/vue3-gettext

Implement JetBrains `web-types.json` file for Vue template type hinting

BusterNeece opened this issue · 4 comments

I've been implementing vue3-gettext in my application, and I've noticed that the $gettext calls in templates themselves, while they resolve correctly within Vue, are being treated by the JetBrains IDE as unknown function calls, which causes them to appear as warnings, show up in inspection results, etc...

JetBrains has a standardized file type to define types in Vue component files (which is particularly useful for templates), and as long as such a file exists for it to reference, it'll be able to smartly identify the $gettext and other related function calls.

The schema for this file is here: https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json

Another project, BootstrapVue, automatically generates this file (along with type-hinting for the VSCode Vetur extension) with this script: https://github.com/bootstrap-vue/bootstrap-vue/blob/dev/scripts/create-web-types.js

If there's interest in adding support for this, I'd be happy to look into possibly submitting a PR.

Hi @BusterNeece, we provide types for the functions etc. here, these should be picked up by the IDE (VSCode Vue Language Features/Volar does this, Vetur should only be used for Vue 2 projects afaik).

I'm unfamiliar with the JetBrains Vue integration, but it seems to work out of the box for one of our customers working in IDEA, so maybe there is some project configuration issue?

I'll leave this open for now, so if others have the same issue they can notify us here. I probably wouldn't decline a PR but I would like to make sure that it really is something the package should provide.

Perhaps it could be a misconfiguration on my part...on Vue single page component files, inside the template component, each of the $gettext calls look like this:

2023-01-03 10_42_36-AzuraCast – Stations_Branding vue

Of course, anywhere I directly import $gettext via composition calls, that works and resolves just fine, it just seems like my IDE doesn't recognize that $gettext is a global function available in all templates.