TypeScriptToLua-T

raw JSON →
0.0.0 verified Fri May 01 auth: no javascript maintenance

A fork of TypeScriptToLua (TSTL) that replaces the TypeScript dependency with typescript-t for compatibility with ttypescript. It transpiles TypeScript code into Lua, supporting the full TypeScript type system and emitting idiomatic Lua output. This version is based on TSTL v0.20.0. It is not actively maintained by the original authors and is intended for projects using ttypescript. Key differentiators: custom TypeScript compiler fork integration, same API as TSTL.

error Cannot find module 'typescript-to-lua'
cause Package name is typescript-to-lua-t, not typescript-to-lua.
fix
Install and import from 'typescript-to-lua-t'.
error Cannot find module 'typescript'
cause The fork requires typescript-t, which may not be installed.
fix
Run: npm install typescript-t
breaking This fork uses typescript-t instead of typescript. Ensure typescript-t is installed and compatible.
fix Install typescript-t and remove typescript: npm install typescript-t && npm uninstall typescript
gotcha Import paths must use 'typescript-to-lua-t' not 'typescript-to-lua'.
fix Replace 'typescript-to-lua' with 'typescript-to-lua-t' in imports.
deprecated The original TSTL v0.20.0 API is used; newer TSTL versions may have changes.
fix Refer to TSTL v0.20.0 documentation for API specifics.
npm install typescript-to-lua-t
yarn add typescript-to-lua-t
pnpm add typescript-to-lua-t

Transpile a simple TypeScript variable declaration to Lua using the fork.

import { transpileString } from 'typescript-to-lua-t';

const luaCode = transpileString('const x: number = 1;', {
  luaTarget: '5.3',
  noHeader: true,
});

console.log(luaCode); // Outputs: local x = 1