|
1 | 1 | <div align="center"> |
2 | 2 | <img src="logo-hq.png?raw=true" alt="TypeScriptToLua" width="256" /> |
3 | 3 | <h1> |
4 | | - TypeScriptToLua |
5 | | - <p></p> |
6 | | - <a href="https://github.com/TypeScriptToLua/TypeScriptToLua/actions"><img alt="Continuous Integration status" src="https://github.com/TypeScriptToLua/TypeScriptToLua/workflows/CI/badge.svg" /></a> |
| 4 | + <p>TypeScriptToLua</p> |
| 5 | + <a href="https://github.com/TypeScriptToLua/TypeScriptToLua/actions"><img alt="CI status" src="https://github.com/TypeScriptToLua/TypeScriptToLua/workflows/CI/badge.svg" /></a> |
7 | 6 | <a href="https://codecov.io/gh/TypeScriptToLua/TypeScriptToLua"><img alt="Coverage" src="https://img.shields.io/codecov/c/gh/TypeScriptToLua/TypeScriptToLua.svg?logo=codecov" /></a> |
8 | 7 | <a href="https://discord.gg/BWAq58Y"><img alt="Chat with us!" src="https://img.shields.io/discord/515854149821267971.svg?colorB=7581dc&logo=discord&logoColor=white"></a> |
9 | 8 | </h1> |
| 9 | + <a href="https://typescripttolua.github.io/" target="_blank">Documentation</a> |
| 10 | + | |
| 11 | + <a href="https://typescripttolua.github.io/play/" target="_blank">Try Online</a> |
| 12 | + | |
| 13 | + <a href="https://github.com/TypeScriptToLua/TypeScriptToLua/blob/master/CHANGELOG.md">Changelog</a> |
| 14 | + | |
| 15 | + <a href="https://github.com/TypeScriptToLua/TypeScriptToLua/blob/master/CONTRIBUTING.md">Contribution guidelines</a> |
10 | 16 | </div> |
11 | 17 |
|
12 | | -A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua! |
13 | | - |
14 | | -Large projects written in lua can become hard to maintain and make it easy to make mistakes. Writing code in TypeScript instead improves maintainability, readability and robustness, with the added bonus of good IDE support. This project is useful in any environment where Lua code is accepted, with the powerful option of simply declaring any existing API using TypeScript declaration files. |
15 | | - |
16 | | -## Documentation |
17 | | - |
18 | | -More detailed documentation and info on writing declarations can be found [on the wiki](https://github.com/TypeScriptToLua/TypescriptToLua/wiki). |
19 | | - |
20 | | -Changelog can be found in [CHANGELOG.md](https://github.com/TypeScriptToLua/TypescriptToLua/blob/master/CHANGELOG.md) |
21 | | - |
22 | | -## Usage Guide |
23 | | - |
24 | | -**Install** |
25 | | - |
26 | | -`npm install -g typescript-to-lua` |
27 | | - |
28 | | -**Compile Files** |
29 | | - |
30 | | -`tstl path/to/file.ts path/to/other-file.ts` |
| 18 | +--- |
31 | 19 |
|
32 | | -**Compile Projects** |
| 20 | +A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua! |
33 | 21 |
|
34 | | -`tstl -p path/to/tsconfig.json` |
| 22 | +Large projects written in Lua can become hard to maintain and make it easy to make mistakes. Writing code in TypeScript instead improves maintainability, readability and robustness, with the added bonus of good [tooling] support (including [ESLint], [Prettier], [Visual Studio Code] and [WebStorm]). This project is useful in any environment where Lua code is accepted, with the powerful option of simply declaring any existing API using TypeScript declaration files. |
35 | 23 |
|
36 | | -**Compile project in watch mode** |
| 24 | +[tooling]: https://typescripttolua.github.io/docs/editor-support |
| 25 | +[eslint]: https://eslint.org/ |
| 26 | +[prettier]: https://prettier.io/ |
| 27 | +[visual studio code]: https://code.visualstudio.com/ |
| 28 | +[webstorm]: https://www.jetbrains.com/webstorm/ |
37 | 29 |
|
38 | | -`tstl -p path/to/tsconfig.json --watch` |
| 30 | +## Getting Started |
39 | 31 |
|
40 | | -**Example tsconfig.json** |
| 32 | +To install TypeScriptToLua add the `typescript-to-lua` npm package: |
41 | 33 |
|
42 | | -```json |
43 | | -{ |
44 | | - "compilerOptions": { |
45 | | - "target": "esnext", |
46 | | - "lib": ["esnext"], |
47 | | - "strict": true |
48 | | - }, |
49 | | - "tstl": { |
50 | | - "luaTarget": "JIT" |
51 | | - } |
52 | | -} |
| 34 | +```bash |
| 35 | +$ npm install -D typescript-to-lua |
53 | 36 | ``` |
54 | 37 |
|
55 | | -## Contributing |
56 | | - |
57 | | -All contributions are welcome, but please read our [contribution guidelines](https://github.com/TypeScriptToLua/TypescriptToLua/blob/master/CONTRIBUTING.md)! |
58 | | - |
59 | | -## Declarations |
60 | | - |
61 | | -The real power of this transpiler is usage together with good declarations for the Lua API provided. Some examples of Lua interface declarations can be found here: |
62 | | - |
63 | | -- [Dota 2 Modding](https://github.com/ModDota/API/tree/master/declarations/server) |
64 | | -- [Defold Game Engine Scripting](https://github.com/dasannikov/DefoldTypeScript/blob/master/defold.d.ts) |
65 | | -- [LÖVE 2D Game Development](https://github.com/hazzard993/love-typescript-definitions) |
66 | | -- [World of Warcraft - Addon Development](https://github.com/wartoshika/wow-declarations) |
67 | | -- [World of Warcraft Classic - Addon Development](https://github.com/wartoshika/wow-classic-declarations) |
68 | | - |
69 | | -## Sublime Text integration |
70 | | - |
71 | | -This compiler works great in combination with the [Sublime Text Typescript plugin](https://github.com/Microsoft/TypeScript-Sublime-Plugin) (available through the package manager as `TypeScript`). |
72 | | - |
73 | | -You can simply open your typescript project assuming a valid tsconfig.json file is present. The default TypeScript plugin will provide all functionality of a regular TypeScript project. |
74 | | - |
75 | | -### Setting up a custom build system |
76 | | - |
77 | | -To add the option to build with the Lua transpiler instead of the regular typescript compiler, go to `Tools > Build System > New Build System...`. In the new sublime-build file that opens, enter the following (adjust path to tstl if not installed globally): |
| 38 | +This package includes the `tstl` command line application, which can be used similarly to `tsc`: |
78 | 39 |
|
79 | 40 | ``` |
80 | | -{ |
81 | | - "cmd": ["tstl", "-p", "$file"], |
82 | | - "shell": true |
83 | | -} |
| 41 | +$ npx tstl |
84 | 42 | ``` |
85 | 43 |
|
86 | | -Save this in your Sublime settings as a `TypeScriptToLua.sublime-build`. You can now select the TypeScriptToLua build system in `Tools > Build System` to build using the normal hotkey (`ctrl+B`), or if you have multiple TypeScript projects open, you can choose your compiler before building by pressing `ctrl+shift+B`. |
| 44 | +For more information, check out [Getting Started](https://typescripttolua.github.io/docs/getting-started) in our documentation. |
0 commit comments