-
|
In crates/emmylua_code_analysis/resources/std/os.lua we have, e.g.: ---@class std.osdateparam
---@field …In crates/emmylua_code_analysis/resources/std/io.lua we have: -- File object
---@class file
local file = {}But also: ---@alias iolib.OpenMode …And: ---@alias std.readmode
---| …I'm trying to understand the logic to these conventions. Why is Are the conventions and their logic documented somewhere? Or is it just that you inherited a mess from IntelliJ Emmylua as mentioned in #922 (comment) and there is no logic/system to it? Finally, is Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
As you can see, it's a mess. Lowercase class names are usually inherited — not only from IntelliJ Emmylua, but some were copied from LuaLS as well. To make the two type systems as compatible as possible in practice, we generally treat built-in types as lowercase. We also believe classes with complex generic capabilities should be capitalized; this convention comes from TypeScript. The std prefix is added to prevent conflicts with user-defined types. |
Beta Was this translation helpful? Give feedback.
-
|
Note that we have the concept of namespaces, although almost nobody uses them; namespaces do not need to be declared explicitly — a namespace is created automatically when you declare a class using a dot like: |
Beta Was this translation helpful? Give feedback.
-
|
OK, I understand it would take some hard thinking to decide how to best rework this, and some hard decisions regarding compatibility with LuaLS, and that it is probably not top priority. Thanks for the clarification at least of why it is what it is! |
Beta Was this translation helpful? Give feedback.
As you can see, it's a mess. Lowercase class names are usually inherited — not only from IntelliJ Emmylua, but some were copied from LuaLS as well. To make the two type systems as compatible as possible in practice, we generally treat built-in types as lowercase. We also believe classes with complex generic capabilities should be capitalized; this convention comes from TypeScript. The std prefix is added to prevent conflicts with user-defined types.