LuaLS / LuaLS/lua-language-server
Nested Table Type Narrowing
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lua
- Star
- 4.4k
- Fork
- 442
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
It would be super nice to be able to get field suggestions when narrowing an indice of a nested table.
Currently this:
---@class TestClass
---@field test_group_a TestGroupA
---@field test_group_b TestGroupB
---@class TestGroupA : TestGroupCommon
---@field test_field_1 string
---@field test_field_2 string
---@class TestGroupB : TestGroupCommon
---@field test_field_1 string
---@field test_field_3 string
---@class TestGroupCommon
---@field test_field_common string
---@type TestClass
local test_class
---@type 'test_group_a' | 'test_group_b'
local test_group
local test1 = test_class[test_group].test_field_1
---------------------------------------
---@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 TestTable
local test_table
---@type "test_group_a" | "test_group_b"
local test_table_group
local test2 = test_table[test_table_group].test_field_1
The inferred type for test1 and test2 are both unknown. It would be nice if for test1 and test2 the inferred type would be string (as test_field_1 is a string for both, if test_field_1 and test_field_2 differed the inferred the type should be test_field_1_type | test_field_2_type). It would also be nice if on local test1 = test_class[test_group]. there were field suggestions for test_field_1 and test_field_common which are on both TestGroupA and TestGroupB.
Note: to add this for classes would also require doing: https://github.com/LuaLS/lua-language-server/issues/2217
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện hai ví dụ Lua trong issue và kiểm tra các đường dẫn của language-server xử lý truy cập theo chỉ mục, thu hẹp kiểu và hoàn thành trường. Được xem là hoàn tất khi cả hai ví dụ đều suy luận string cho test_field_1 và cung cấp các trường được chia sẻ bởi những kiểu bảng lồng nhau có thể có, đồng thời tính đến issue liên quan về thu hẹp lớp 2217.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- devtools
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100