Skip to content

How to describe __call metamethod? #724

Answered by lua-rocks
lua-rocks asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, I found not perfect, but still a solution.

I can give such functions a name using @alias annotation:

---@alias lib.ansicolors_call fun(str: string): string

...

---@type lib.ansicolors|lib.ansicolors_call
local ansicolors = require 'lib.ansicolors'

The problem is that this approach does not describe the actual function in the code and requires specifying the type after each require, but it works nevertheless.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lua-rocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant