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
|`luaTarget`|`"JIT"`, `"5.3"`, `"5.2"`, `"5.1"`, `"universal"` (default: `"universal"`) | Specifies the Lua version you want to generate code for. Choosing `universal` makes TypeScriptToLua generate code compatible with all supported Lua targets. |
29
-
|`noImplicitSelf`|`true`, `false` (default: `false`) | If true, treats all project files as if they were prefixed with<br />`/** @noSelfInFile **/`. |
30
-
|`noHeader`|`true`, `false` (default: `false`) | Set this to true if you don't want to include our header in the output. |
31
-
|`luaLibImport`|`"inline"`, `"require"`, `"always"`, `"none"` (default: `"require"`) | We polyfill certain JavaScript features with Lua functions, this option specifies how these functions are imported into the Lua output. |
32
-
|`sourceMapTraceback`|`true`, `false` (default: `false`) | Overrides Lua's `debug.traceback` to apply sourcemaps to Lua stacktraces. This will make error messages point to your original TypeScript code instead of the generated Lua. |
33
-
|`luaBundle`| File path (relative to the `tsconfig.json`) | Will bundle all output lua files into a single bundle file. Requires **luaBundleEntry** to be set! |
34
-
|`luaBundleEntry`| File path (relative to the `tsconfig.json`) | This should be the name/path of the TS file in your project that will serve as entry point to the bundled code. |
35
-
|`luaPlugins`|`Array<{ name: string; import?: string }>`| List of [TypeScriptToLua plugins](api/plugins.md). |
36
-
|`buildMode`|`"default"`, `"library"` (default: `"library"`) | Use `buildMode: "library"` to build [publishable library packages](publishing-modules.md). |
37
-
|`tstlVerbose`|`true`, `false` (default: `false`) | Output additional logging when performing a tstl build, to help diagnose issues. |
|`luaTarget`|`"JIT"`, `"5.3"`, `"5.2"`, `"5.1"`, `"universal"` (default: `"universal"`) | Specifies the Lua version you want to generate code for. Choosing `universal` makes TypeScriptToLua generate code compatible with all supported Lua targets. |
29
+
|`noImplicitSelf`|`true`, `false` (default: `false`) | If true, treats all project files as if they were prefixed with<br />`/** @noSelfInFile **/`. |
30
+
|`noHeader`|`true`, `false` (default: `false`) | Set this to true if you don't want to include our header in the output. |
31
+
|`luaLibImport`|`"inline"`, `"require"`, `"always"`, `"none"` (default: `"require"`) | We polyfill certain JavaScript features with Lua functions, this option specifies how these functions are imported into the Lua output. |
32
+
|`sourceMapTraceback`|`true`, `false` (default: `false`) | Overrides Lua's `debug.traceback` to apply sourcemaps to Lua stacktraces. This will make error messages point to your original TypeScript code instead of the generated Lua. |
33
+
|`luaBundle`| File path (relative to the `tsconfig.json`) | Will bundle all output lua files into a single bundle file. Requires **luaBundleEntry** to be set! |
34
+
|`luaBundleEntry`| File path (relative to the `tsconfig.json`) | This should be the name/path of the TS file in your project that will serve as entry point to the bundled code. |
35
+
|`luaPlugins`|`Array<{ name: string; import?: string }>`| List of [TypeScriptToLua plugins](api/plugins.md). |
36
+
|`buildMode`|`"default"`, `"library"` (default: `"library"`) | Use `buildMode: "library"` to build [publishable library packages](publishing-modules.md). |
37
+
|`tstlVerbose`|`true`, `false` (default: `false`) | Output additional logging when performing a tstl build, to help diagnose issues. |
38
+
|`noResolvePaths`|`Array<string>`| An array of require paths that will **NOT** be resolved. For example `["require1", "sub.require2"]` will stop tstl from trying to resolve Lua sources for `require("require1")` and `require("sub.require2")`. |
TypeScriptToLua supports importing JSON files into your TypeScript. This is done by translating the JSON file to Lua and simply including this Lua file as part of the transpiler output.
6
+
7
+
# Example
8
+
9
+
Consider the following project files:
10
+
11
+
```
12
+
./
13
+
├── main.ts
14
+
├── myjsondata.json
15
+
└── tsconfig.json
16
+
```
17
+
18
+
## Modifying tsconfig.json
19
+
20
+
To be able to import JSON files you have to enable the `resolveJsonModule` option in tsconfig.json, and set `moduleResolution` to node:
21
+
22
+
```json title=tsconfig.json
23
+
{
24
+
"compilerOptions": {
25
+
"moduleResolution": "node",
26
+
"resolveJsonModule": true
27
+
}
28
+
}
29
+
```
30
+
31
+
## Json data
32
+
33
+
The file containing JSON is just standard JSON:
34
+
35
+
```json title=myjsondata.json
36
+
{
37
+
"property1": "foo",
38
+
"property2": "bar"
39
+
}
40
+
```
41
+
42
+
## Importing JSON data
43
+
44
+
Now to access your data, simply import it from your TS file:
0 commit comments