You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/caveats.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Caveats
3
3
---
4
4
5
-
Luckily, for most use-cases, you can write modern, idiomatic TypeScript, and TSTL will produce transpiled Lua that will work flawlessly. In other words, you probably will not have to worry about the idiomatic quirks of Lua or the internal decisions that TSTL makes when converting code.
5
+
TSTL aims to support almost all modern, idiomatic TypeScript without any modifications. In other words, you probably will not have to worry about the idiomatic quirks of Lua or other internal decisions that TSTL makes when converting code.
6
6
7
7
With that said, TSTL does have some "gotchas" that you might run into. This page covers some of those edge-cases.
8
8
@@ -21,7 +21,7 @@ With that said, TSTL does have some "gotchas" that you might run into. This page
21
21
22
22
## Differences from JavaScript
23
23
24
-
This project aims for both compilation results to have the same behavior as much as possible, but not at all costs. Since TypeScript is based on JavaScript, it also inherited some of the quirks in JavaScript that are not present in Lua. This is where behavior between Lua and JavaScript compilation targets diverge. TypeScriptToLua aims to keep identical behavior as long as **sane** TypeScript is used: if JavaScript-specific quirks are used, behavior might differ.
24
+
This project aims for JavaScript and Lua compilation results to have the same runtime behavior as much as possible, but not at all costs. Since TypeScript is based on JavaScript, it also inherited some of the quirks in JavaScript that are not present in Lua. This is where behavior between Lua and JavaScript compilation targets diverge. TypeScriptToLua aims to keep identical behavior as long as **sane** TypeScript is used: if JavaScript-specific quirks are used, behavior might differ.
25
25
26
26
Below are some of the cases where resulting Lua intentionally behaves different from compiled JS.
27
27
@@ -118,7 +118,7 @@ A sorting algorithm is [said to be stable](https://stackoverflow.com/questions/1
118
118
119
119
TypeScriptToLua relies on the Lua standard library for sorting. In other words, it transpiles `[1, 2, 3].sort();` to `table.sort({1, 2, 3})`. So beware that your sorts will no longer be stable!
120
120
121
-
If you need stable sorting, you have to manually use a custom sorting function. For some examples of this, see the [sorting helper functions from `isaacscript-common`](https://github.com/IsaacScript/isaacscript/blob/main/packages/isaacscript-common/src/functions/sort.ts).
121
+
If you need stable sorting, you will have to implement your own sorting algorithm or find a library that provides one.
Copy file name to clipboardExpand all lines: docs/external-code.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: External Code
3
3
---
4
4
5
-
In your `tstl` project, you might want to import some existing Lua code. Or, you might want to import a library from [npm](https://www.npmjs.com/). This page describes how to use external code.
5
+
In your `tstl` project, you might want to use some existing Lua code. Or you might want to import a Lua library from [npm](https://www.npmjs.com/). This page describes how to use external Lua with your TypeScript code and TSTL.
6
6
7
7
:::note
8
8
This page is about importing code that **actually executes something**. In a `tstl` project, it is common to depend on external library that provide type declarations. Type declaration libraries only provide types: they do not contribute any code to your actual program output. Thus, they work a little differently from what is discussed on this page. For information on how type declarations work, see the [type declarations page](advanced/writing-declarations.md).
Copy file name to clipboardExpand all lines: docs/getting-started.md
+2-26Lines changed: 2 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,14 +11,7 @@ Note that we assume that you are already familiar with how TypeScript works. If
11
11
TypeScriptToLua is built using [Node.js](https://nodejs.org/) and distributed via [npm](https://www.npmjs.com/). To install it, you need to create a `package.json` file in the root of your project, containing at least `{}`. Then, you can add the latest version of TypeScriptToLua to your project:
(If you don't know the difference between the package managers, choose `npm`.)
@@ -49,39 +42,22 @@ TypeScriptToLua is configured using a `tsconfig.json` file. (This is the same fi
49
42
}
50
43
```
51
44
52
-
If your target Lua environment is not [LuaJIT](https://luajit.org/), make sure to change the value of `luaTarget`. Valid values are `JIT`, `5.3`, `5.2`, `5.1`, `5.0`, and `universal`.
45
+
Make sure to set the value of `luaTarget` to the Lua version of your environment. Valid values are `JIT`, `5.4`, `5.3`, `5.2`, `5.1`, `5.0`, and `universal`.
53
46
54
47
:::note
55
48
You can find out the version of your Lua environment by running: `print(_VERSION)`
56
49
:::
57
50
58
51
Check out [configuration page](configuration.md) for more information.
59
52
60
-
### Strictest Configuration
61
-
62
-
If you want the TypeScript compiler to be as strict as possible, then you need to enable some additional flags. Handily, we can extend from [the "strictest" TypeScript community config](https://github.com/tsconfig/bases/blob/main/bases/strictest.json) to abstract this away by adding this to top of the `tsconfig.json` file:
0 commit comments