Registry / web-framework / typescript-to-lua-dev

typescript-to-lua-dev

JSON →
library0.41.1jsnpmunverified

A transpiler that converts TypeScript code into Lua, enabling developers to write Lua applications using TypeScript's type system and tooling. Version 0.41.1 is the current stable release, with a regular release cadence (minor updates every few months). It supports Lua 5.1-5.4, LuaJIT, and Roblox Lua. Key differentiators: generates readable Lua, supports source maps, and integrates with TSTL plugin ecosystem. Unlike other transpilers, it preserves TypeScript structure.

npm install typescript-to-lua-dev
INSTALL
IMPORT
SIG · TYPESCRIPT-TO-LUA-
T
typescript-to-lua-dev
web-frameworkjavascriptv0.41.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

transpileString
import { transpileString } from 'typescript-to-lua'
const transpileString = require('typescript-to-lua').transpileString
ESM-only since v1; CommonJS require() may work but is not recommended.
transpileFiles
import { transpileFiles } from 'typescript-to-lua'
Use for programmatic batch transpilation. Accepts an array of file paths.
LuaTarget
import { LuaTarget } from 'typescript-to-lua'
import LuaTarget from 'typescript-to-lua'
LuaTarget is a named export, not default.

Demonstrates basic programmatic transpilation of a TypeScript function to Lua using transpileString API.

import { transpileString } from 'typescript-to-lua'; const tsCode = `function greet(name: string): string { return 'Hello, ' + name; } `; const luaCode = transpileString(tsCode, { luaTarget: '5.3', sourceMap: true }); console.log(luaCode); // Output: local function greet(name) // return 'Hello, ' .. name // end
tstl --version
Debug
Known issues
breakingBREAKING CHANGE: TypeScriptToLua v0.20.0 renames the `LuaTarget` enum values to lowercase (e.g., '5.3' previously 'Lua53').
fix
Update enum references: use '5.3', '5.2', etc. instead of 'Lua53', 'Lua52'.
affects: >=0.20.0 <0.21.0
breakingBREAKING CHANGE: v0.36.0 drops support for Node.js <12.
fix
Upgrade Node.js to v12 or later. Use LTS version.
affects: >=0.36.0
gotchaDefault export changed: in v0.15.0, the default export was the transpiler function; use named exports instead.
fix
Replace `import tstl from 'typescript-to-lua'` with `import { transpileString } from 'typescript-to-lua'`.
affects: >=0.15.0
deprecated`transpile` function is deprecated since v0.30.0; use `transpileString` or `transpileFiles`.
fix
Replace calls to `transpile` with `transpileString` for single code strings, or `transpileFiles` for files.
affects: >=0.30.0
Errors
Common errors & fixes
Cannot find module 'typescript-to-lua'
Package not installed or not in node_modules.
fix
Run: npm install -D typescript-to-lua (or yarn add -D typescript-to-lua)
Error: Invalid Lua target: '5.1'. Must be one of: '5.3', '5.4', 'JIT', '5.2'
Passed '5.1' which is not a valid target; TSTL does not support Lua 5.1 directly.
fix
Use one of: '5.2', '5.3', '5.4', 'JIT'. For Lua 5.1 compatibility, use '5.2' or transform manually.
TypeError: transpileString is not a function
Incorrect import (CommonJS vs ESM) or using old API.
fix
Use ESM import: import { transpileString } from 'typescript-to-lua'. If using CommonJS, use const { transpileString } = require('typescript-to-lua').
ERROR: The 'transpileFiles' option 'sourceRoot' must be a string.
Passed a non-string value (e.g., number or array) to sourceRoot in options.
fix
Ensure sourceRoot is an absolute or relative path string, e.g., './src'.
Upgrade
Version history
0.41.1latest on npm
Audit
Dependencies
lua-typesoptionalTypeScript declarations for Lua standard library and APIs (e.g., math, table)
Agent activity
4 hits · last 30 days
node
4
Resources
typescript-to-lua-dev — npm install typescript-to-lua-dev · libregistry