Lua2TypeScript is a partial-coverage Lua-to-TypeScript translator and proof-of-concept. It is not a general Lua 5.4 implementation, and it is not actively developed. I have no plans to finish it. This repository is prepared as an experimental snapshot of one approach to translating Lua source into refactorable TypeScript.
The translator was designed to preserve Lua-specific semantics at explicit bridge boundaries: tables with mixed keys, metatables, multiple returns, varargs, environments, coroutines, and Lua's integer/float distinction.
v0.1 - inactive proof-of-concept, partial Lua 5.4 coverage. The parser and runtime experiments cover meaningful pieces of Lua, but the project did not reach full end-to-end parity with the Lua reference implementation. It should not be treated as a maintained Lua compiler or a production dependency.
Treat Lua2TypeScript as a research artifact. It is useful for studying how Lua runtime semantics might be represented in TypeScript, not as a finished translator.
- Lua parser coverage for many real Lua files used during development.
- Experimental Lua runtime support for tables, metatables, multiple returns, coroutines, and standard-library subsets.
- Optional C API bridge experiments for embedding-oriented cases.
- Shared translator infrastructure for source maps, dependency graphs, diagnostics, and validation.
The project did not reach a published, fully passing ts-lua runtime parity milestone.
- Full Lua 5.4 coverage was not reached.
- Runtime parity with the reference Lua interpreter is incomplete.
- Standard-library coverage is partial.
- C API embedding support is experimental.
- Unsupported constructs should be treated as outside the experiment, even where partial code paths exist.
This repository is not presented as a polished npm package or maintained CLI. The commands below describe the intended shape of the prototype interface, but expect rough edges in the checked-in snapshot.
Translate a Lua file:
npx lua2typescript --input path/to/script.lua --output path/to/script.tsRun the translated program:
node path/to/script.tsLua2TypeScript emits to vendored runtime libraries with literal names:
vendor/lua-parser/- Lua parser experiments.vendor/lua-runtime/- Lua table, metatable, stack, coroutine, and standard-library runtime experiments.vendor/lua-c-api-bridge/- optional bridge support for Lua C API embedding patterns.vendor/c-pointer-layout/- shared pointer and layout model used by C-side bridge code.vendor/posix-runtime/- POSIX-shaped surfaces used by translated programs.
The repository also vendors translator-support libraries: source-mapping/, compile-db/, dep-graph/, conformance/, and validation-harness/.
Lua2TypeScript is a sibling experimental translator snapshot:
- C2TypeScript - C17 to TypeScript; the most complete of the three.
- Lua2TypeScript - Lua 5.4 to TypeScript; partial and inactive.
- Cpp2TypeScript - C++20 to TypeScript; partial and inactive.
MIT - see LICENSE.
Scott Moore.