-
-
Notifications
You must be signed in to change notification settings - Fork 357
meta
| doc/meta
- type annotation in different file
#3071
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
Comments
meta
| doc/meta
- type annotation in different file, something like .d.ts
meta
| doc/meta
- type annotation in different file, like .d.ts
meta
| doc/meta
- type annotation in different file, like .d.ts
meta
| doc/meta
- type annotation in different file
Which version of LuaLS did you use?
NOTE: I'm no author or maintainer, below are just my own opinions and use experience.
However I don't think separating meta file for you own implementation is the best practice in LuaLS 🤔 meta files are for API documentationMeta files are primarily used for documenting API of a native library or 3rd party library, rather than being used for type inference within your implementation. That's because you cannot change the source code of that 3rd party library to add annotation. And for library written in native code, you simply have no way to add annotation. the
|
@tomlau10 Thanks for the answer!!! Yes, I am using the old version
By the way, 3rds may be a lua module and, as it seems strange, using it can cause type checking errors. And, in general, I think of it as a header file, which is often used to explain and declare. But if your opinion is even close to being correct, that's great. Maybe it should just be described more clearly, or I should spend more time thinking about it. |
Uh oh!
There was an error while loading. Please reload this page.
I see two ways: it is not well-documented or it is not provided, as I think. Or I just a duplicate these
Given: Lua file with classes (or just functions, maybe even local) without type annotations.
Needed: Create type annotations to provide suggestions, etc.
Maybe I'm wrong, but I think changing files that contain classes is a bad idea because it mixes the logic of the type with the flow of the program.
I didn't find a way to divide it.
I suggest it should look like
class_meta.lua
orclass.meta.lua
class.lua
But it is not working with the redefined error.
Then i try to use
@overload
annotation, butBut it doesn't work either.
Also, there is a way to annotate all methods with @field, which makes initialization noisy and ugly, and doesn't give compilation suggestions for the method body. So, type annotations are needed again.
class.lua
The text was updated successfully, but these errors were encountered: