Description
Introduction
Lua used by Tarantool has dynamic type system. It may complicate the development of the Tarantool applications because of lack of static checks and absence of IDE/text editor autocomplete support since types of the values can't be inferred before script execution. There are tools such as Lua Language Server (ex. Sumneko Lua Server) [1] allowing providing type annotations and class definitions for performing some static checks. There is a Tarantool VSCode extension [2] for Lua Language Server with type definitions for the most of the Tarantool functions. The problem is that the extension is maintained externally. It means some of the type definitions are deprecated and aren't used in the internal code during the development.
Suggestion
It's suggested to migrate the type definitions inside the Tarantool itself and to provide a straightforward way to supply IDE with type definitions for performing static checks when developing Tarantool. It'd good to reuse the language server checks during the development to make new code more reliable, simplify the development and review process. Also, this type definitions may involve documentation on the functions thus they can be reused for exporting documentation reference.
Implementation
Adding the support includes the following tasks.
- Migrate and actualize type definitions for C-defined Lua functions and Lua modules from the VSCode extension [2]. Since there are a lot of modules it's suggested to work in three iterations.
-
box
,clock
,config
,decimal
,fiber
,json
,log
,net.box
,string
,table
,uri
,uuid
,yaml
modules (lua: add basic Lua Language Server support #11038). -
buffer
,csv
,datetime
,digest
,fio
,fun
,http
,merger
,pickle
,socket
,utf8
. -
crypto
,iconv
,popen
,strict
,swim
,xlog
.
-
- Support exporting definition files for Lua Language Server [3] for developing Tarantool applications (lua: add basic Lua Language Server support #11038).
- Migrate and provide type definitions for popular Tarantool modules.
-
vshard
-
luatest
-
crud
-
queue
-
expirationd
-
kafka
- Likely, something else.
-
- Implement building plugins for popular text editors: Neovim, VSCode.
- Bulid a PoC of exporting Lua function documentation reference from type definitions.
- Add type definitions for internal Lua methods and classes.
- Add support for explicitly specifying space schema for providing static checks of the database tuples.
- Include static checks of the Lua Language Server in CI.
- Require the developer to supply type definitions for new Lua functions.
Iterations
Since the task is even too big for a single epic, it's split into iterations.