refactor(test): add type annotations for the child object #1110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, I'm a big fan of type annotations, since they are helping writing code. It's far from perfect in lua, but it's still helpful. Working with child object is a very frequent task and I always wanted completions for
child.api
for example. I did a first step to that goal in my fork and quiet happy with the results. I thought that it can be useful for someone else too. But since that PR #437 (comment) I remembered that this is not really that important for you. If you decide to close this, that's OK. I think I can use a fork with type annotations added (and I can even add expectations and new methods there instead of helpers in each project).I want to improve type annotations for some other public functions too, like
new_set()
that is often used when writing tests (I have a trouble remembering thatpre_case
is not a top level attribute, but a sub-attribute ofhooks
).In helpers it's expected to use something like:
This way
helpers.child
will have all original and added methods annotated. But for lua-language-server actually recognize it, helpers need to be required, not dofiled.Also it can be used like this:
The only issue is with
mini.doc
. It doesn't recognize@return
tag correctly.@return
tag can be:<type>
<type> #<comment>
<type> <var name>
<type> <var name> <comment>
So it would be helpful for
mini.doc
to support custom types (not only standard). So that doc text matches what is a type, and what is a comment.