{"id":26551,"library":"typescript-to-lua-dev","title":"TypeScriptToLua","description":"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.","status":"active","version":"0.41.1","language":"javascript","source_language":"en","source_url":"https://github.com/TypeScriptToLua/TypeScriptToLua","tags":["javascript","typescript","lua","tstl","transpiler"],"install":[{"cmd":"npm install typescript-to-lua-dev","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-to-lua-dev","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-to-lua-dev","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"TypeScript declarations for Lua standard library and APIs (e.g., math, table)","package":"lua-types","optional":true}],"imports":[{"note":"ESM-only since v1; CommonJS require() may work but is not recommended.","wrong":"const transpileString = require('typescript-to-lua').transpileString","symbol":"transpileString","correct":"import { transpileString } from 'typescript-to-lua'"},{"note":"Use for programmatic batch transpilation. Accepts an array of file paths.","wrong":"","symbol":"transpileFiles","correct":"import { transpileFiles } from 'typescript-to-lua'"},{"note":"LuaTarget is a named export, not default.","wrong":"import LuaTarget from 'typescript-to-lua'","symbol":"LuaTarget","correct":"import { LuaTarget } from 'typescript-to-lua'"}],"quickstart":{"code":"import { transpileString } from 'typescript-to-lua';\n\nconst tsCode = `function greet(name: string): string {\n  return 'Hello, ' + name;\n}\n`;\n\nconst luaCode = transpileString(tsCode, {\n  luaTarget: '5.3',\n  sourceMap: true\n});\n\nconsole.log(luaCode);\n// Output: local function greet(name)\n//     return 'Hello, ' .. name\n// end","lang":"typescript","description":"Demonstrates basic programmatic transpilation of a TypeScript function to Lua using transpileString API."},"warnings":[{"fix":"Update enum references: use '5.3', '5.2', etc. instead of 'Lua53', 'Lua52'.","message":"BREAKING CHANGE: TypeScriptToLua v0.20.0 renames the `LuaTarget` enum values to lowercase (e.g., '5.3' previously 'Lua53').","severity":"breaking","affected_versions":">=0.20.0 <0.21.0"},{"fix":"Upgrade Node.js to v12 or later. Use LTS version.","message":"BREAKING CHANGE: v0.36.0 drops support for Node.js <12.","severity":"breaking","affected_versions":">=0.36.0"},{"fix":"Replace `import tstl from 'typescript-to-lua'` with `import { transpileString } from 'typescript-to-lua'`.","message":"Default export changed: in v0.15.0, the default export was the transpiler function; use named exports instead.","severity":"gotcha","affected_versions":">=0.15.0"},{"fix":"Replace calls to `transpile` with `transpileString` for single code strings, or `transpileFiles` for files.","message":"`transpile` function is deprecated since v0.30.0; use `transpileString` or `transpileFiles`.","severity":"deprecated","affected_versions":">=0.30.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: npm install -D typescript-to-lua (or yarn add -D typescript-to-lua)","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'typescript-to-lua'"},{"fix":"Use one of: '5.2', '5.3', '5.4', 'JIT'. For Lua 5.1 compatibility, use '5.2' or transform manually.","cause":"Passed '5.1' which is not a valid target; TSTL does not support Lua 5.1 directly.","error":"Error: Invalid Lua target: '5.1'. Must be one of: '5.3', '5.4', 'JIT', '5.2'"},{"fix":"Use ESM import: import { transpileString } from 'typescript-to-lua'. If using CommonJS, use const { transpileString } = require('typescript-to-lua').","cause":"Incorrect import (CommonJS vs ESM) or using old API.","error":"TypeError: transpileString is not a function"},{"fix":"Ensure sourceRoot is an absolute or relative path string, e.g., './src'.","cause":"Passed a non-string value (e.g., number or array) to sourceRoot in options.","error":"ERROR: The 'transpileFiles' option 'sourceRoot' must be a string."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}