LuaLS / LuaLS/lua-language-server
Template Annotation
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ả
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.
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 với chẩn đoán missing-fields hiện có và phần xử lý chú thích liên quan đến ---@type. Xác định cách một chú thích ---@template có thể mô tả cấu trúc của một bảng mà không yêu cầu mọi trường, sau đó xác minh rằng ví dụ sử dụng Weapons.unit không còn tạo ra cảnh báo, trong khi các kiểm tra trường bị thiếu thông thường vẫn được giữ nguyên.
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 30/100