LuaLS / LuaLS/lua-language-server
Template Annotation
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
既存の missing-fields 診断と、---@type に関係するアノテーション処理から始めます。すべてのフィールドを必須にせずに ---@template アノテーションでテーブルの形状を記述する方法を検討し、次に Weapons.unit を使用する例で警告が生成されなくなり、通常の欠落フィールドチェックは引き続き維持されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100