Teal
Browse docs
Teal is a statically typed dialect of lua by the creator of LuaRocks.
It is intended to become the TypeScript of Lua, and ships its compiler via luarocks.
Teal support ships built-in to lde.
Any .tl files in your src dir will automatically be compiled ahead of time to lua into your target directory.
Quickstart
- Run this and cd into it:
lde new --language teal ./hello-tealThe scaffold writes src/init.tl as the entry point, adds a check script to lde.json so lde check runs the Teal compiler’s checker, and drops in a tlconfig.lua with target/ on the include path.
- Replace
src/init.tlwith:
local greet = require("hello-teal.greet")
local count: integer = 41
print(greet("world"), count + 1)- Make
src/greet.tl:
local function greet(name: string): string
return "hello, " .. name
end
return greet- Run it with
lde run
The output is:
hello, world 42The file src/init.tl is the entry point. This is the same as src/init.lua for packages that use Lua.
Type checking with tl check
Since no type checking is performed on run, to check your code, you can run the tl compiler using ldx.
ldx rocks:tl check -I target src/init.tlThis works because lde preserves the .tl sources in your target/ alongside the compiled .lua files.
We can add this as a package script for easy use as lde check:
{
"scripts": {
"check": "ldx rocks:tl check -I target src/init.tl src/greet.tl"
}
}Then you can simply run a type check as so:
lde check