Registry / devops / luau2ts

luau2ts

JSON →
library0.3.2jsnpmunverified

A Luau-to-TypeScript compiler for Roblox (v0.3.2). It transpiles Luau source code into TypeScript, enabling migration of Luau codebases to TypeScript, parallel runtime maintenance, or integration with TS-native tooling. Features include two emit modes (rbxts for roblox-ts compatibility, native for Roblox-native API), directory and Rojo-project mode with declaration file generation, 100% passing conformance tests, and full Roblox API coverage. Published on npm, requires Node >=18, and ships TypeScript types.

npm install luau2ts
INSTALL
IMPORT
SIG · LUAU2TS
L
luau2ts
devopsjavascriptv0.3.2
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.

compile
import { compile } from 'luau2ts'
const { compile } = require('luau2ts')
Package is ESM-only. CJS require will fail. Use dynamic import if needed.
compileFile
import { compileFile } from 'luau2ts'
Same as compile but reads from file. Also ESM-only.
compileProject
import { compileProject } from 'luau2ts'
Used for Rojo project conversion. Returns an array of compile results.

Compiles a Luau source string to TypeScript using the library API.

import { compile } from 'luau2ts'; const code = ` local function greet(name) print("Hello, " .. name) end `; const result = await compile(code, { mode: 'native' }); console.log(result.source); // function greet(name) { // print(`Hello, ${name}`); // }
Debug
Known issues
breakingIn v0.3.0, the API changed from synchronous to async. compile() and compileFile() now return Promises.
fix
Add await to calls to compile(), compileFile(), and compileProject().
affects: >=0.3.0
deprecatedThe --jsx flag is deprecated. Use --mode native for native JSX-style syntax.
fix
Replace --jsx with --mode native.
affects: >=0.2.0
gotchaThe library is ESM-only. Using require('luau2ts') throws an error.
fix
Use import statements or dynamic import() in CJS projects.
affects: >=0.3.0
gotchaWhen using mode 'rbxts', compiled output expects roblox-ts types (@rbxts/types). Missing types cause TS errors.
fix
Install @rbxts/types and @rbxts/services as dev dependencies.
affects: >=0.1.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/luau2ts/index.mjs from /path/to/project/index.js not supported.
Package is ESM-only, but project uses CommonJS require().
fix
Switch to import syntax: import { compile } from 'luau2ts'
TypeError: compile is not a function
Importing the default export instead of named exports, or using outdated version.
fix
Use import { compile } from 'luau2ts' (named export) and ensure version >=0.3.0.
Cannot find module '@rbxts/types' or its corresponding type declarations.
Compiled output in rbxts mode requires roblox-ts type packages.
fix
Run: npm install --save-dev @rbxts/types @rbxts/services
Error: Expected a string, but got an object.
First argument to compile() must be a string, but an options object was passed instead.
fix
Pass source code string as first argument and options as second: compile(code, options).
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
luau2ts — npm install luau2ts · libregistry