LuaLS / LuaLS/lua-language-server
Type Narrow Exact Strings
オープン
まだ誰も着手していません。
enhancement
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Another feature suggestion 😅
It would be useful to be able to type-narrow exact strings.
For example:
---@alias TestTable {test_group_a: {test_field_1: string, test_field_2: string}, test_group_b: {test_field_1: string, test_field_3: string}}
---@type "test_group_a" | "test_group_b"
local test
if test == "test_group_a" then
---@type TestTable
local test_table
test1 = test_table[test].test_field_1
end
When we do if test == "test_group_a" then it would be nice if the type of test narrowed to test_group_a (which can then be used to successfully index test_table. As it is now there is no type narrowing so the inferred type of test1 is unknown when it should be string.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue の Lua 例が提供されている唯一のエントリーポイントです。これを使って、test と test1 の現在の型を再現してください。"test_group_a" との等価性チェックによって test が TestTable のインデックスに使えるところまで絞り込まれ、test1 が string として推論されること(提示されたケースのカバレッジを含む)が完了の条件です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- compilers, devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100