Registry / devops / typescript-to-lua-fixed

typescript-to-lua-fixed

JSON →
library1.0.1jsnpmunverified

A generic TypeScript to Lua transpiler that lets you write TypeScript code and compile it to Lua. This package (v1.0.1) is a fork requiring TypeScript ~4.4.3. It provides a command-line tool (`tstl`) similar to `tsc`. Key differentiators: preserves TypeScript type safety in Lua projects; supports declaration files for existing Lua APIs; integrates with standard TS tooling (ESLint, Prettier). Release cadence is sporadic; check upstream TypeScriptToLua for active development.

npm install typescript-to-lua-fixed
INSTALL
IMPORT
SIG · TYPESCRIPT-TO-LUA-
T
typescript-to-lua-fixed
devopsjavascriptv1.0.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.

transpile
import { transpile } from 'typescript-to-lua'
import transpile from 'typescript-to-lua'
ESM named export; default import not supported.
transpileString
import { transpileString } from 'typescript-to-lua'
const transpileString = require('typescript-to-lua').transpileString
ESM-only package; use import, not require.
compile
import { compile } from 'typescript-to-lua'
Same as transpile; alternative name for the same function.
LuaTranspiler
import { LuaTranspiler } from 'typescript-to-lua'
Type export for TypeScript users.

Demonstrates transpiling a TypeScript class to Lua using 'transpileString' and file-based transpilation with 'transpile'.

import { transpileString } from 'typescript-to-lua'; import { transpile } from 'typescript-to-lua'; import * as ts from 'typescript'; // Example: transpile a simple TypeScript class const source = ` class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } } `; const result = transpileString(source, { luaTarget: "5.3", noHeader: true }); console.log(result.file?.lua); // Output: // Greeter = {} // function Greeter.new(self, message) // self.greeting = message // return self // end // function Greeter.greet(self) // return "Hello, " .. self.greeting // end // For file-based transpilation: const program = ts.createProgram(['./input.ts'], {}); const emitResult = transpile(program, { luaTarget: '5.3' }); console.log(emitResult.emitSkipped ? 'Emit skipped' : 'Emit succeeded');
tstl --version
Debug
Known issues
gotchaThis is a fixed fork of the original TypeScriptToLua. Use the original for latest features and updates.
fix
Consider using 'typescript-to-lua' (original) instead unless you specifically need this fork's fixes.
affects: >=1.0.0
gotchaRequires TypeScript ~4.4.3 as a peer dependency. Incompatible with newer TypeScript versions (4.5+).
fix
Install TypeScript 4.4.3: npm install -D typescript@~4.4.3
affects: >=1.0.0
gotchaThe 'transpileString' function returns an object with a 'file' property; access 'file.lua' to get the Lua code.
fix
Use result.file?.lua to obtain the output.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'typescript-to-lua'
Package not installed or missing from node_modules.
fix
npm install -D typescript-to-lua
TypeError: transpileString is not a function
Default import used incorrectly (import transpileString from '...') or CommonJS require used.
fix
Use named import: import { transpileString } from 'typescript-to-lua'
error TS2688: Cannot find type definition file for 'typescript-to-lua'.
TypeScript cannot locate types for the package.
fix
Ensure 'typescript-to-lua' is installed and types are bundled (they are). May need to add 'typescript-to-lua' to 'types' in tsconfig.json.
The 'transpile' function requires a TypeScript Program object, not source code.
Confusing transpile with transpileString.
fix
Use transpileString for string input, or create a ts.Program using ts.createProgram for file-based input.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
typescriptrequiredPeer dependency: requires TypeScript ~4.4.3 to perform transpilation.
Agent activity
4 hits · last 30 days
node
4
Resources
typescript-to-lua-fixed — npm install typescript-to-lua-fixed · libregistry