Skip to content
Back to skills

Writing Typescript To Lua

ASecurity

Use when writing or editing TypeScript that compiles to Lua with TSTL 1.24+ for game scripting, Defold, or an embedded engine. Triggers on `.ts` files with a TSTL config, `LuaMultiReturn`, `@noSelf`, namespaces, decorators, or calls across the Lua boundary, even when the user doesn't say 'TSTL'.

  • 6 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 30, 2026
ai-agentstypescriptgoperformance

Works with

  • cli

Security analysis

A100/100

Pro scans all 14 files and shows the line behind each finding

Scanned November 30, 2026

npx -y skills add xonovex/platform --skill writing-typescript-to-lua --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Writing Typescript To Lua?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Writing Typescript To Lua
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/xonovex-writing-typescript-to-lua/badge)](https://www.skillsdirectory.com/skills/xonovex-writing-typescript-to-lua)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: writing-typescript-to-lua
description: "Use when writing or editing TypeScript that compiles to Lua with TSTL 1.24+ for game scripting, Defold, or an embedded engine. Triggers on `.ts` files with a TSTL config, `LuaMultiReturn`, `@noSelf`, namespaces, decorators, or calls across the Lua boundary, even when the user doesn't say 'TSTL'."
---

# TypeScript-to-Lua Coding Guidelines

The output is Lua. For Lua runtime semantics and idioms: module pattern, coroutines, metatables, error handling, string building. Apply **writing-lua**, which also covers hot-path tuning of the generated code. This skill covers only the TS→Lua transpiler boundary: what translates, how to shape TS source for clean Lua, and TSTL-specific features.

## Requirements

- TSTL ≥ 1.24; TS strict mode; Lua ≥ 5.3 / LuaJIT 2.1.

## Essentials

- **Code organization** - Favor namespaces/functions over classes for clean Lua output; Lua module idioms in **writing-lua**, see [references/namespaces-vs-classes.md](references/namespaces-vs-classes.md)
- **TSTL features** - Use LuaMultiReturn, decorators when beneficial, see [references/multi-return-functions.md](references/multi-return-functions.md), [references/tstl-decorators.md](references/tstl-decorators.md)
- **Performance** - Keep tables stable, cache lookups, design for Lua GC and coroutines; the JIT "why" is in **writing-lua**, see [references/performance-tips.md](references/performance-tips.md), [references/coroutine-patterns.md](references/coroutine-patterns.md)
- **Optimization** - Avoid heavy TypeScript features, see [references/avoiding-heavy-features.md](references/avoiding-heavy-features.md)

## Gotchas

- Not all TypeScript features translate: generators, `for-await-of`, dynamic `import()`, and BigInt are unsupported or partially supported
- Translation is source-to-source; runtime semantics follow Lua, not JS: `0` and `""` are truthy in Lua, falsy in JS
- Lua's table indexing (1-based, no `length` for holes) replaces JS arrays: pass-through types abstract this but iteration order changes
- Importing JS-only libraries silently fails at translation, only `@types` packages with Lua-runtime equivalents work
- `tstlc` is the CLI; build configs are different from `tsc`: sharing a `tsconfig.json` with web projects requires careful `compilerOptions` split

## Progressive disclosure

- Read [references/namespaces-vs-classes.md](references/namespaces-vs-classes.md) - Load when choosing code organization, namespaces, or enums for clean Lua output
- Read [references/multi-return-functions.md](references/multi-return-functions.md) - Load when implementing Lua-style multiple return values
- Read [references/coroutine-patterns.md](references/coroutine-patterns.md) - Load when implementing cooperative multitasking
- Read [references/lua-interop.md](references/lua-interop.md) - Load when calling Lua code from TypeScript
- Read [references/tstl-decorators.md](references/tstl-decorators.md) - Load when using TSTL-specific decorators
- Read [references/performance-tips.md](references/performance-tips.md) - Load when optimizing for Lua GC/JIT or generated code is slow or bloated
- Read [references/type-safety.md](references/type-safety.md) - Load when maintaining types across TS/Lua boundary
- Read [references/avoiding-heavy-features.md](references/avoiding-heavy-features.md) - Load when transpiled output is unexpectedly large
- Read [references/tsconfig.md](references/tsconfig.md) - Load when configuring TSTL compiler options

Files in this skill

  • SKILL.md3.4 KB
  • eval-output.json3.1 KB
  • eval-trigger.json5.8 KB
  • moon.yml119 B
  • references/avoiding-heavy-features.md586 B
  • references/coroutine-patterns.md674 B
  • references/lua-interop.md587 B
  • references/multi-return-functions.md899 B
  • references/namespaces-vs-classes.md672 B
  • references/performance-tips.md1.3 KB
  • references/tsconfig.md670 B
  • references/tstl-decorators.md845 B
  • references/type-safety.md691 B
  • sources.json1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.