{"id":26552,"library":"typescript-to-fivem-lua","title":"TypeScriptToLua","description":"A generic TypeScript to Lua transpiler, version 1.27.0. Write TypeScript code and transpile it to Lua for use in environments like FiveM. This fork modifies class construction from metatables to functions inside the table. Releases follow TypeScriptToLua upstream with some delays. Key differentiators: transpiles TypeScript to Lua for game modding (FiveM, Garry's Mod), leverages full TypeScript tooling (editor support, ESLint, Prettier). Requires TypeScript 5.6.2 as a peer dependency. Active development with regular updates.","status":"active","version":"1.27.0","language":"javascript","source_language":"en","source_url":"https://github.com/JaRoLoz/TypeScriptToFiveMLua","tags":["javascript","typescript","lua","tstl","transpiler"],"install":[{"cmd":"npm install typescript-to-fivem-lua","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-to-fivem-lua","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-to-fivem-lua","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for transpilation","package":"typescript","optional":false}],"imports":[{"note":"Package is ESM-only; CJS require will fail.","wrong":"const tslua = require('typescript-to-fivem-lua')","symbol":"tslua","correct":"import tslua from 'typescript-to-fivem-lua'"},{"note":"Type import for configuration objects.","symbol":"TranspileOptions","correct":"import { TranspileOptions } from 'typescript-to-fivem-lua'"},{"note":"luaLib is a named export, not default.","wrong":"import luaLib from 'typescript-to-fivem-lua'","symbol":"luaLib","correct":"import { luaLib } from 'typescript-to-fivem-lua'"},{"note":"Function to transpile a string of TypeScript code.","symbol":"transpileString","correct":"import { transpileString } from 'typescript-to-fivem-lua'"}],"quickstart":{"code":"import { transpileString } from 'typescript-to-fivem-lua';\n\nconst tsCode = `\nfunction greet(name: string): string {\n    return `Hello, ${name}!`;\n}\n`;\n\nconst luaCode = transpileString(tsCode, {\n    luaTarget: '5.3',\n    noHeader: true,\n});\n\nconsole.log(luaCode);\n// Output:\n// function greet(name)\n//     return \"Hello, \" .. name .. \"!\"\n// end","lang":"typescript","description":"Transpiles a simple TypeScript function to Lua using transpileString."},"warnings":[{"fix":"Update any Lua interop code that relies on metatable class structure to handle function-based classes.","message":"This fork changes class construction from metatables to functions inside the table. Existing Lua code expecting metatable-based classes will break.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use 'luaVersion' instead of 'luaTarget' in transpile options.","message":"The 'luaTarget' option may be deprecated in future versions; prefer 'luaVersion'.","severity":"deprecated","affected_versions":">=1.20.0"},{"fix":"Include luaLib: 'inherit' in transpile options to inject necessary Lua polyfills.","message":"TypeScript standard library features (e.g., Map, Set, Array methods) may not be supported unless Lua lib is injected.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade Node.js to version 16.10.0 or later.","message":"Version 1.25.0 dropped Node <16 support.","severity":"breaking","affected_versions":">=1.25.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 typescript-to-fivem-lua typescript@5.6.2'","cause":"Package not installed or npm install failed.","error":"Error: Cannot find module 'typescript-to-fivem-lua'"},{"fix":"Change import to: import { luaLib } from 'typescript-to-fivem-lua'","cause":"luaLib is imported as default instead of named export.","error":"TypeError: luaLib is not a function"},{"fix":"Use import statements or set type: 'module' in package.json, or switch to dynamic import.","cause":"Attempting to use ESM syntax with CommonJS require or non-ESM context.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}