I often wish that there was a TypeScript-style variant of Lua which offered optional type declarations to help catch errors.
Actually, there is a typed variant of Lua in active development:
Also, there’s a TypeScript to Lua transpiler:
https://typescripttolua.github.io/
And we have several language definition files ready to rumble…including those for Defold:
I can’t personally speak for Defold ones, but I recently tried a VSCode + TypeScriptToLua + LÖVE setup and it worked like a charm. You can have the transpiler running in background and doing the work automatically too.
Last but not least, if you like to keep working with plain Lua, you can try this plugin for IntelliJ that leverages EmmyLua comments to do both intellisense and type checks: