Registry / devops / typescript-to-fivem-lua

typescript-to-fivem-lua

JSON →
library1.27.0jsnpmunverified

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.

npm install typescript-to-fivem-lua
INSTALL
IMPORT
SIG · TYPESCRIPT-TO-FIVE
T
typescript-to-fivem-lua
devopsjavascriptv1.27.0
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.

tslua
✓ import tslua from 'typescript-to-fivem-lua'
✗ const tslua = require('typescript-to-fivem-lua')
Package is ESM-only; CJS require will fail.
TranspileOptions
✓ import { TranspileOptions } from 'typescript-to-fivem-lua'
Type import for configuration objects.
luaLib
✓ import { luaLib } from 'typescript-to-fivem-lua'
✗ import luaLib from 'typescript-to-fivem-lua'
luaLib is a named export, not default.
transpileString
✓ import { transpileString } from 'typescript-to-fivem-lua'
Function to transpile a string of TypeScript code.

Transpiles a simple TypeScript function to Lua using transpileString.

import { transpileString } from 'typescript-to-fivem-lua'; const tsCode = ` function greet(name: string): string { return `Hello, ${name}!`; } `; const luaCode = transpileString(tsCode, { luaTarget: '5.3', noHeader: true, }); console.log(luaCode); // Output: // function greet(name) // return "Hello, " .. name .. "!" // end
tstl --version
Debug
Known issues
breakingThis fork changes class construction from metatables to functions inside the table. Existing Lua code expecting metatable-based classes will break.
fix
Update any Lua interop code that relies on metatable class structure to handle function-based classes.
affects: >=1.0.0
deprecatedThe 'luaTarget' option may be deprecated in future versions; prefer 'luaVersion'.
fix
Use 'luaVersion' instead of 'luaTarget' in transpile options.
affects: >=1.20.0
gotchaTypeScript standard library features (e.g., Map, Set, Array methods) may not be supported unless Lua lib is injected.
fix
Include luaLib: 'inherit' in transpile options to inject necessary Lua polyfills.
affects: all
breakingVersion 1.25.0 dropped Node <16 support.
fix
Upgrade Node.js to version 16.10.0 or later.
affects: >=1.25.0
Errors
Common errors & fixes
Error: Cannot find module 'typescript-to-fivem-lua'
Package not installed or npm install failed.
fix
Run 'npm install typescript-to-fivem-lua typescript@5.6.2'
TypeError: luaLib is not a function
luaLib is imported as default instead of named export.
fix
Change import to: import { luaLib } from 'typescript-to-fivem-lua'
SyntaxError: Unexpected token 'export'
Attempting to use ESM syntax with CommonJS require or non-ESM context.
fix
Use import statements or set type: 'module' in package.json, or switch to dynamic import.
Upgrade
Version history
1.27.0latest on npm
Audit
Dependencies
typescriptrequiredpeer dependency for transpilation
Agent activity
12 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
typescript-to-fivem-lua — npm install typescript-to-fivem-lua · libregistry