LuaLS / LuaLS/lua-language-server
Template Annotation
Personne n'a encore pris cette issue.
- Langage dominant
- Lua
- Étoiles
- 4.4k
- Forks
- 442
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I love the new missing-fields diagnostic! It is super helpful to guarantee safety especially for function arguments (though its usefullness in my repo has stagnated slightly due to https://github.com/LuaLS/lua-language-server/issues/2214)
However, it does come into conflict with something I do in a few places where I specifically set a type annotation for the autocomplete where the data in the table is initialized later in a meta_table (or the data is only every accessible through the meta_table).
---@type WeaponsUnitData
Weapons.unit = {}
setmetatable(Weapons.unit, Metatable.unit_metatable())
With the new missing-fields diagnostic I get a warning here, that Weapons.unit doesn't contain all of the fields on WeaponsUnitData. I was wondering with the missing-fields diagnostic we could get a ---@template annotation which could describe the shape of a table without having to define all of the fields on it. (As a cleaner alternative to having to do ---@diagnostic disable-next-line: missing-fields in a bunch of places). I am sure other people were also using tables in other weird ways before as well, this would allow an easy transition for them.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le diagnostic existant missing-fields et par le traitement des annotations utilisé avec ---@type. Déterminez comment une annotation ---@template pourrait décrire la structure d’une table sans exiger tous les champs, puis vérifiez que l’exemple utilisant Weapons.unit ne produit plus l’avertissement, tout en préservant les vérifications normales des champs manquants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- lua
- Domaine
- devtools
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 30/100