Skip to content

Basic partial class support #3024

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 4 commits into from
Jan 13, 2025
Merged

Conversation

tomlau10
Copy link
Contributor

@tomlau10 tomlau10 commented Jan 3, 2025

resolves #3023, resolves #2561


Since #2970, the partial class "hack" for not checking missing inherited fields no longer works.
This PR brings back this feature by introducing a partial attribute for @class.
A class marked with partial will not check missing inherited fields, just like the original checking behavior.

Example

---@class Config
---@field a number

---@class (partial) Config.P: Config
---@field b number

---@type Config.P[]
local cfgs = {}
cfgs[1] = { b = 1 } -- no warning
cfgs[2] = {}        -- only warns missing `b`

中文版

#2970 起,原有的 partial class hack 被封了。
這個 PR 對 @class 簡單地引入 partial 屬性
=> 帶 partial 屬性的 class 在檢查 missing fields 時會忽略 inherited class 的字段,就像之前的 check logic 一樣

a class marked with partial will not check missing inherited fields
@sumneko sumneko merged commit 4396730 into LuaLS:master Jan 13, 2025
11 checks passed
@sumneko
Copy link
Collaborator

sumneko commented Jan 13, 2025

Thank you!

@tomlau10 tomlau10 deleted the feat/basic_partial_class branch January 14, 2025 01:04
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

关于诊断缺少继承的字段 [Future Ruquest] An easy way to create a partial of a class
2 participants