@defold-typescript/types 0.5.5 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/api-targets.json +1 -1
  3. package/generated/b2d.d.ts +3 -0
  4. package/generated/buffer.d.ts +44 -38
  5. package/generated/builtin-messages.d.ts +1 -1
  6. package/generated/camera.d.ts +3 -0
  7. package/generated/collectionfactory.d.ts +47 -40
  8. package/generated/collectionproxy.d.ts +23 -18
  9. package/generated/crash.d.ts +3 -0
  10. package/generated/factory.d.ts +32 -24
  11. package/generated/go.d.ts +123 -124
  12. package/generated/graphics.d.ts +3 -0
  13. package/generated/gui.d.ts +303 -283
  14. package/generated/http.d.ts +26 -16
  15. package/generated/iac.d.ts +3 -0
  16. package/generated/iap.d.ts +6 -3
  17. package/generated/image.d.ts +30 -26
  18. package/generated/json.d.ts +36 -32
  19. package/generated/kinds/gui-script.d.ts +7 -5
  20. package/generated/kinds/render-script.d.ts +7 -5
  21. package/generated/kinds/script.d.ts +7 -5
  22. package/generated/label.d.ts +16 -9
  23. package/generated/liveupdate.d.ts +29 -26
  24. package/generated/model.d.ts +57 -45
  25. package/generated/msg.d.ts +3 -0
  26. package/generated/particlefx.d.ts +50 -34
  27. package/generated/physics.d.ts +153 -133
  28. package/generated/profiler.d.ts +45 -41
  29. package/generated/push.d.ts +5 -2
  30. package/generated/render.d.ts +410 -349
  31. package/generated/resource.d.ts +619 -572
  32. package/generated/socket.d.ts +49 -33
  33. package/generated/sound.d.ts +83 -72
  34. package/generated/sprite.d.ts +3 -0
  35. package/generated/sys.d.ts +198 -189
  36. package/generated/tilemap.d.ts +43 -39
  37. package/generated/timer.d.ts +42 -36
  38. package/generated/vmath.d.ts +22 -0
  39. package/generated/webview.d.ts +3 -0
  40. package/generated/window.d.ts +23 -17
  41. package/generated/zlib.d.ts +15 -12
  42. package/index.d.ts +3 -1
  43. package/package.json +13 -2
  44. package/scripts/fidelity-audit.ts +61 -1
  45. package/scripts/fidelity-baseline.json +10 -10
  46. package/scripts/ref-doc-delta.ts +143 -0
  47. package/scripts/regen.ts +18 -9
  48. package/src/core-types.ts +14 -0
  49. package/src/emit-dts.ts +219 -13
  50. package/src/engine-globals.d.ts +2 -0
  51. package/src/go-overloads.d.ts +43 -0
  52. package/src/index.ts +5 -0
  53. package/src/lifecycle.ts +157 -16
  54. package/src/publish-dts.ts +1 -1
@@ -2,6 +2,10 @@
2
2
  import type { Opaque } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions and messages for using system resources, controlling the engine,
7
+ * error handling and debugging.
8
+ */
5
9
  namespace sys {
6
10
  /**
7
11
  * network connected through other, non cellular, connection
@@ -21,10 +25,10 @@ declare global {
21
25
  * @param buffer - buffer to deserialize from
22
26
  * @returns lua table with deserialized data
23
27
  * @example
24
- * ```lua
25
- * Deserialize a lua table that was previously serialized:
26
- * local buffer = sys.serialize(my_table)
27
- * local table = sys.deserialize(buffer)
28
+ * ```ts
29
+ * // Deserialize a table that was previously serialized:
30
+ * const buffer = sys.serialize(my_table);
31
+ * const table = sys.deserialize(buffer);
28
32
  * ```
29
33
  */
30
34
  function deserialize(buffer: string): Record<string | number, unknown>;
@@ -35,12 +39,12 @@ declare global {
35
39
  * @param path - path to check
36
40
  * @returns `true` if the path exists, `false` otherwise
37
41
  * @example
38
- * ```lua
39
- * Load data but return nil if path didn't exist
40
- * if not sys.exists(path) then
41
- * return nil
42
- * end
43
- * return sys.load(path) -- returns {} if it failed
42
+ * ```ts
43
+ * // Load data but return nil if path didn't exist
44
+ * if (!sys.exists(path)) {
45
+ * return undefined;
46
+ * }
47
+ * return sys.load(path); // returns {} if it failed
44
48
  * ```
45
49
  */
46
50
  function exists(path: string): boolean;
@@ -49,13 +53,16 @@ declare global {
49
53
  *
50
54
  * @param code - exit code to report to the OS, 0 means clean exit
51
55
  * @example
52
- * ```lua
53
- * This examples demonstrates how to exit the application when some kind of quit messages is received (maybe from gui or similar):
54
- * function on_message(self, message_id, message, sender)
55
- * if message_id == hash("quit") then
56
- * sys.exit(0)
57
- * end
58
- * end
56
+ * ```ts
57
+ * // This example demonstrates how to exit the application when some kind of quit
58
+ * // message is received (maybe from gui or similar):
59
+ * export default defineScript({
60
+ * on_message(self, message_id, message, sender) {
61
+ * if (message_id === hash("quit")) {
62
+ * sys.exit(0);
63
+ * }
64
+ * },
65
+ * });
59
66
  * ```
60
67
  */
61
68
  function exit(code: number): void;
@@ -71,28 +78,28 @@ declare global {
71
78
  * `installed`
72
79
  * boolean `true` if the application is installed, `false` otherwise.
73
80
  * @example
74
- * ```lua
75
- * Check if twitter is installed:
76
- * sysinfo = sys.get_sys_info()
77
- * twitter = {}
78
- *
79
- * if sysinfo.system_name == "Android" then
80
- * twitter = sys.get_application_info("com.twitter.android")
81
- * elseif sysinfo.system_name == "iPhone OS" then
82
- * twitter = sys.get_application_info("twitter:")
83
- * end
84
- *
85
- * if twitter.installed then
86
- * -- twitter is installed!
87
- * end
88
- *
89
- * Info.plist for the iOS app needs to list the schemes that are queried:
90
- * ...
91
- * <key>LSApplicationQueriesSchemes</key>
92
- * <array>
93
- * <string>twitter</string>
94
- * </array>
95
- * ...
81
+ * ```ts
82
+ * // Check if twitter is installed:
83
+ * const sysinfo = sys.get_sys_info();
84
+ * let twitter = {};
85
+ *
86
+ * if (sysinfo.system_name === "Android") {
87
+ * twitter = sys.get_application_info("com.twitter.android");
88
+ * } else if (sysinfo.system_name === "iPhone OS") {
89
+ * twitter = sys.get_application_info("twitter:");
90
+ * }
91
+ *
92
+ * if (twitter.installed) {
93
+ * // twitter is installed!
94
+ * }
95
+ *
96
+ * // Info.plist for the iOS app needs to list the schemes that are queried:
97
+ * // ...
98
+ * // <key>LSApplicationQueriesSchemes</key>
99
+ * // <array>
100
+ * // <string>twitter</string>
101
+ * // </array>
102
+ * // ...
96
103
  * ```
97
104
  */
98
105
  function get_application_info(app_string: string): { installed: boolean };
@@ -102,26 +109,26 @@ declare global {
102
109
  *
103
110
  * @returns path to application executable
104
111
  * @example
105
- * ```lua
106
- * Find a path where we can store data (the example path is on the macOS platform):
107
- * -- macOS: /Applications/my_game.app
108
- * local application_path = sys.get_application_path()
109
- * print(application_path) --> /Applications/my_game.app
112
+ * ```ts
113
+ * // Find a path where we can store data (the example path is on the macOS platform):
114
+ * // macOS: /Applications/my_game.app
115
+ * const application_path = sys.get_application_path();
116
+ * print(application_path); //> /Applications/my_game.app
110
117
  *
111
- * -- Windows: C:\Program Files\my_game\my_game.exe
112
- * print(application_path) --> C:\Program Files\my_game
118
+ * // Windows: C:\Program Files\my_game\my_game.exe
119
+ * print(application_path); //> C:\Program Files\my_game
113
120
  *
114
- * -- Linux: /home/foobar/my_game/my_game
115
- * print(application_path) --> /home/foobar/my_game
121
+ * // Linux: /home/foobar/my_game/my_game
122
+ * print(application_path); //> /home/foobar/my_game
116
123
  *
117
- * -- Android package name: com.foobar.my_game
118
- * print(application_path) --> /data/user/0/com.foobar.my_game
124
+ * // Android package name: com.foobar.my_game
125
+ * print(application_path); //> /data/user/0/com.foobar.my_game
119
126
  *
120
- * -- iOS: my_game.app
121
- * print(application_path) --> /var/containers/Bundle/Applications/123456AB-78CD-90DE-12345678ABCD/my_game.app
127
+ * // iOS: my_game.app
128
+ * print(application_path); //> /var/containers/Bundle/Applications/123456AB-78CD-90DE-12345678ABCD/my_game.app
122
129
  *
123
- * -- HTML5: http://www.foobar.com/my_game/
124
- * print(application_path) --> http://www.foobar.com/my_game
130
+ * // HTML5: http://www.foobar.com/my_game/
131
+ * print(application_path); //> http://www.foobar.com/my_game
125
132
  * ```
126
133
  */
127
134
  function get_application_path(): string;
@@ -132,9 +139,9 @@ declare global {
132
139
  * @param default_value - (optional) default value to return if the value does not exist
133
140
  * @returns config value as a boolean. default_value if the config key does not exist. false if no default value was supplied.
134
141
  * @example
135
- * ```lua
136
- * Get user config value
137
- * local vsync = sys.get_config_boolean("display.vsync", false)
142
+ * ```ts
143
+ * // Get user config value
144
+ * const vsync = sys.get_config_boolean("display.vsync", false);
138
145
  * ```
139
146
  */
140
147
  function get_config_boolean(key: string, default_value?: boolean): boolean;
@@ -145,14 +152,14 @@ declare global {
145
152
  * @param default_value - (optional) default value to return if the value does not exist
146
153
  * @returns config value as an integer. default_value if the config key does not exist. 0 if no default value was supplied.
147
154
  * @example
148
- * ```lua
149
- * Get user config value
150
- * local speed = sys.get_config_int("my_game.speed", 20) -- with default value
151
- *
152
- * local testmode = sys.get_config_int("my_game.testmode") -- without default value
153
- * if testmode ~= nil then
154
- * -- do stuff
155
- * end
155
+ * ```ts
156
+ * // Get user config value
157
+ * const speed = sys.get_config_int("my_game.speed", 20); // with default value
158
+ *
159
+ * const testmode = sys.get_config_int("my_game.testmode"); // without default value
160
+ * if (testmode !== undefined) {
161
+ * // do stuff
162
+ * }
156
163
  * ```
157
164
  */
158
165
  function get_config_int(key: string, default_value?: number): number;
@@ -163,9 +170,9 @@ declare global {
163
170
  * @param default_value - (optional) default value to return if the value does not exist
164
171
  * @returns config value as an number. default_value if the config key does not exist. 0 if no default value was supplied.
165
172
  * @example
166
- * ```lua
167
- * Get user config value
168
- * local speed = sys.get_config_number("my_game.speed", 20.0)
173
+ * ```ts
174
+ * // Get user config value
175
+ * const speed = sys.get_config_number("my_game.speed", 20.0);
169
176
  * ```
170
177
  */
171
178
  function get_config_number(key: string, default_value?: number): number;
@@ -176,15 +183,15 @@ declare global {
176
183
  * @param default_value - (optional) default value to return if the value does not exist
177
184
  * @returns config value as a string. default_value if the config key does not exist. nil if no default value was supplied.
178
185
  * @example
179
- * ```lua
180
- * Get user config value
181
- * local text = sys.get_config_string("my_game.text", "default text"))
186
+ * ```ts
187
+ * // Get user config value
188
+ * const text = sys.get_config_string("my_game.text", "default text");
182
189
  *
183
- * Start the engine with a bootstrap config override and add a custom config value
184
- * $ dmengine --config=bootstrap.main_collection=/mytest.collectionc --config=mygame.testmode=1
190
+ * // Start the engine with a bootstrap config override and add a custom config value
191
+ * // $ dmengine --config=bootstrap.main_collection=/mytest.collectionc --config=mygame.testmode=1
185
192
  *
186
- * Read the custom config value from the command line
187
- * local testmode = sys.get_config_int("mygame.testmode")
193
+ * // Read the custom config value from the command line
194
+ * const testmode = sys.get_config_int("mygame.testmode");
188
195
  * ```
189
196
  */
190
197
  function get_config_string(key: string, default_value?: string): string;
@@ -198,11 +205,11 @@ declare global {
198
205
  * - `sys.NETWORK_CONNECTED_CELLULAR` (connected through mobile cellular)
199
206
  * - `sys.NETWORK_CONNECTED` (otherwise, Wifi)
200
207
  * @example
201
- * ```lua
202
- * Check if we are connected through a cellular connection
203
- * if (sys.NETWORK_CONNECTED_CELLULAR == sys.get_connectivity()) then
204
- * print("Connected via cellular, avoid downloading big files!")
205
- * end
208
+ * ```ts
209
+ * // Check if we are connected through a cellular connection
210
+ * if (sys.NETWORK_CONNECTED_CELLULAR === sys.get_connectivity()) {
211
+ * print("Connected via cellular, avoid downloading big files!");
212
+ * }
206
213
  * ```
207
214
  */
208
215
  function get_connectivity(): Opaque<"constant">;
@@ -217,12 +224,12 @@ declare global {
217
224
  * `is_debug`
218
225
  * boolean If the engine is a debug or release version
219
226
  * @example
220
- * ```lua
221
- * How to retrieve engine information:
222
- * -- Update version text label so our testers know what version we're running
223
- * local engine_info = sys.get_engine_info()
224
- * local version_str = "Defold " .. engine_info.version .. "\n" .. engine_info.version_sha1
225
- * gui.set_text(gui.get_node("version"), version_str)
227
+ * ```ts
228
+ * // How to retrieve engine information:
229
+ * // Update version text label so our testers know what version we're running
230
+ * const engine_info = sys.get_engine_info();
231
+ * const version_str = `Defold ${engine_info.version}\n${engine_info.version_sha1}`;
232
+ * gui.set_text(gui.get_node("version"), version_str);
226
233
  * ```
227
234
  */
228
235
  function get_engine_info(): { version: string; version_sha1: string; is_debug: boolean };
@@ -233,14 +240,14 @@ declare global {
233
240
  * @param filename - file to read from
234
241
  * @returns the path prefixed with the proper host mount
235
242
  * @example
236
- * ```lua
237
- * Save data on the host
238
- * local host_path = sys.get_host_path("logs/test.txt")
239
- * sys.save(host_path, mytable)
240
- *
241
- * Load data from the host
242
- * local host_path = sys.get_host_path("logs/test.txt")
243
- * local table = sys.load(host_path)
243
+ * ```ts
244
+ * // Save data on the host
245
+ * const host_path = sys.get_host_path("logs/test.txt");
246
+ * sys.save(host_path, mytable);
247
+ *
248
+ * // Load data from the host
249
+ * const host_path = sys.get_host_path("logs/test.txt");
250
+ * const table = sys.load(host_path);
244
251
  * ```
245
252
  */
246
253
  function get_host_path(filename: string): string;
@@ -259,14 +266,14 @@ declare global {
259
266
  * `running`
260
267
  * boolean `true` if the interface is running, `false` otherwise.
261
268
  * @example
262
- * ```lua
263
- * How to get the IP address of interface "en0":
264
- * ifaddrs = sys.get_ifaddrs()
265
- * for _,interface in ipairs(ifaddrs) do
266
- * if interface.name == "en0" then
267
- * local ip = interface.address
268
- * end
269
- * end
269
+ * ```ts
270
+ * // How to get the IP address of interface "en0":
271
+ * const ifaddrs = sys.get_ifaddrs();
272
+ * for (const iface of ifaddrs) {
273
+ * if (iface.name === "en0") {
274
+ * const ip = iface.address;
275
+ * }
276
+ * }
270
277
  * ```
271
278
  */
272
279
  function get_ifaddrs(): { name: string; address: string; mac: string; up: boolean; running: boolean }[];
@@ -278,27 +285,27 @@ declare global {
278
285
  * @param file_name - file-name to get path for
279
286
  * @returns path to save-file
280
287
  * @example
281
- * ```lua
282
- * Find a path where we can store data:
283
- * local my_file_path = sys.get_save_file("my_game", "my_file")
284
- * -- macOS: /Users/foobar/Library/Application Support/my_game/my_file
285
- * print(my_file_path) --> /Users/foobar/Library/Application Support/my_game/my_file
288
+ * ```ts
289
+ * // Find a path where we can store data:
290
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
291
+ * // macOS: /Users/foobar/Library/Application Support/my_game/my_file
292
+ * print(my_file_path); //> /Users/foobar/Library/Application Support/my_game/my_file
286
293
  *
287
- * -- Windows: C:\Users\foobar\AppData\Roaming\my_game\my_file
288
- * print(my_file_path) --> C:\Users\foobar\AppData\Roaming\my_game\my_file
294
+ * // Windows: C:\Users\foobar\AppData\Roaming\my_game\my_file
295
+ * print(my_file_path); //> C:\Users\foobar\AppData\Roaming\my_game\my_file
289
296
  *
290
- * -- Linux: $XDG_DATA_HOME/my_game/my_file or /home/foobar/.my_game/my_file
291
- * -- Linux: Defaults to /home/foobar/.local/share/my_game/my_file if neither exist.
292
- * print(my_file_path) --> /home/foobar/.local/share/my_game/my_file
297
+ * // Linux: $XDG_DATA_HOME/my_game/my_file or /home/foobar/.my_game/my_file
298
+ * // Linux: Defaults to /home/foobar/.local/share/my_game/my_file if neither exist.
299
+ * print(my_file_path); //> /home/foobar/.local/share/my_game/my_file
293
300
  *
294
- * -- Android package name: com.foobar.packagename
295
- * print(my_file_path) --> /data/data/0/com.foobar.packagename/files/my_file
301
+ * // Android package name: com.foobar.packagename
302
+ * print(my_file_path); //> /data/data/0/com.foobar.packagename/files/my_file
296
303
  *
297
- * -- iOS: my_game.app
298
- * print(my_file_path) --> /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
304
+ * // iOS: my_game.app
305
+ * print(my_file_path); //> /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
299
306
  *
300
- * -- HTML5 path inside the IndexedDB: /data/.my_game/my_file or /.my_game/my_file
301
- * print(my_file_path) --> /data/.my_game/my_file
307
+ * // HTML5 path inside the IndexedDB: /data/.my_game/my_file or /.my_game/my_file
308
+ * print(my_file_path); //> /data/.my_game/my_file
302
309
  * ```
303
310
  */
304
311
  function get_save_file(application_id: string, file_name: string): string;
@@ -331,12 +338,12 @@ declare global {
331
338
  * `user_agent`
332
339
  * string The HTTP user agent, i.e. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8"
333
340
  * @example
334
- * ```lua
335
- * How to get system information:
336
- * local info = sys.get_sys_info()
337
- * if info.system_name == "HTML5" then
338
- * -- We are running in a browser.
339
- * end
341
+ * ```ts
342
+ * // How to get system information:
343
+ * const info = sys.get_sys_info();
344
+ * if (info.system_name === "HTML5") {
345
+ * // We are running in a browser.
346
+ * }
340
347
  * ```
341
348
  */
342
349
  function get_sys_info(options?: { ignore_secure?: boolean }): { device_model: string; manufacturer: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident: string; user_agent: string };
@@ -347,13 +354,13 @@ declare global {
347
354
  * @param filename - file to read from
348
355
  * @returns lua table, which is empty if the file could not be found
349
356
  * @example
350
- * ```lua
351
- * Load data that was previously saved, e.g. an earlier game session:
352
- * local my_file_path = sys.get_save_file("my_game", "my_file")
353
- * local my_table = sys.load(my_file_path)
354
- * if not next(my_table) then
355
- * -- empty table
356
- * end
357
+ * ```ts
358
+ * // Load data that was previously saved, e.g. an earlier game session:
359
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
360
+ * const my_table = sys.load(my_file_path);
361
+ * if (!next(my_table)) {
362
+ * // empty table
363
+ * }
357
364
  * ```
358
365
  */
359
366
  function load(filename: string): Record<string | number, unknown>;
@@ -370,16 +377,16 @@ declare global {
370
377
  *
371
378
  * @param filename - resource to load, full path
372
379
  * @example
373
- * ```lua
374
- * -- Load level data into a string
375
- * local data, error = sys.load_resource("/assets/level_data.json")
376
- * -- Decode json string to a Lua table
377
- * if data then
378
- * local data_table = json.decode(data)
379
- * pprint(data_table)
380
- * else
381
- * print(error)
382
- * end
380
+ * ```ts
381
+ * // Load level data into a string
382
+ * const [data, error] = sys.load_resource("/assets/level_data.json");
383
+ * // Decode json string to a table
384
+ * if (data) {
385
+ * const data_table = json.decode(data);
386
+ * pprint(data_table);
387
+ * } else {
388
+ * print(error);
389
+ * }
383
390
  * ```
384
391
  */
385
392
  function load_resource(filename: string): LuaMultiReturn<[string | unknown, string | unknown]>;
@@ -397,12 +404,12 @@ declare global {
397
404
  * - `name` - The name of the window (Note: the name does not specify the title of the new window).
398
405
  * @returns a boolean indicating if the url could be opened or not
399
406
  * @example
400
- * ```lua
401
- * Open an URL:
402
- * local success = sys.open_url("http://www.defold.com", {target = "_blank"})
403
- * if not success then
404
- * -- could not open the url...
405
- * end
407
+ * ```ts
408
+ * // Open an URL:
409
+ * const success = sys.open_url("http://www.defold.com", { target: "_blank" });
410
+ * if (!success) {
411
+ * // could not open the url...
412
+ * }
406
413
  * ```
407
414
  */
408
415
  function open_url(url: string, attributes?: { target?: string }): boolean;
@@ -420,11 +427,11 @@ declare global {
420
427
  * @param arg5 - argument 5
421
428
  * @param arg6 - argument 6
422
429
  * @example
423
- * ```lua
424
- * How to reboot engine with a specific bootstrap collection.
425
- * local arg1 = '--config=bootstrap.main_collection=/my.collectionc'
426
- * local arg2 = 'build/game.projectc'
427
- * sys.reboot(arg1, arg2)
430
+ * ```ts
431
+ * // How to reboot engine with a specific bootstrap collection.
432
+ * const arg1 = "--config=bootstrap.main_collection=/my.collectionc";
433
+ * const arg2 = "build/game.projectc";
434
+ * sys.reboot(arg1, arg2);
428
435
  * ```
429
436
  */
430
437
  function reboot(arg1?: string, arg2?: string, arg3?: string, arg4?: string, arg5?: string, arg6?: string): void;
@@ -442,12 +449,12 @@ declare global {
442
449
  * @param filename - file to write to
443
450
  * @param table - lua table to save
444
451
  * @example
445
- * ```lua
446
- * Save data:
447
- * local my_table = {}
448
- * table.insert(my_table, "my_value")
449
- * local my_file_path = sys.get_save_file("my_game", "my_file")
450
- * sys.save(my_file_path, my_table)
452
+ * ```ts
453
+ * // Save data:
454
+ * const my_table = [];
455
+ * my_table.push("my_value");
456
+ * const my_file_path = sys.get_save_file("my_game", "my_file");
457
+ * sys.save(my_file_path, my_table);
451
458
  * ```
452
459
  */
453
460
  function save(filename: string, table: Record<string | number, unknown>): void;
@@ -459,11 +466,11 @@ declare global {
459
466
  * @param table - lua table to serialize
460
467
  * @returns serialized data buffer
461
468
  * @example
462
- * ```lua
463
- * Serialize table:
464
- * local my_table = {}
465
- * table.insert(my_table, "my_value")
466
- * local buffer = sys.serialize(my_table)
469
+ * ```ts
470
+ * // Serialize table:
471
+ * const my_table = [];
472
+ * my_table.push("my_value");
473
+ * const buffer = sys.serialize(my_table);
467
474
  * ```
468
475
  */
469
476
  function serialize(table: Record<string | number, unknown>): string;
@@ -472,8 +479,8 @@ declare global {
472
479
  *
473
480
  * @param host - hostname to check against
474
481
  * @example
475
- * ```lua
476
- * sys.set_connectivity_host("www.google.com")
482
+ * ```ts
483
+ * sys.set_connectivity_host("www.google.com");
477
484
  * ```
478
485
  */
479
486
  function set_connectivity_host(host: string): void;
@@ -489,24 +496,26 @@ declare global {
489
496
  * `traceback`
490
497
  * string The stack traceback.
491
498
  * @example
492
- * ```lua
493
- * Install error handler that just prints the errors
494
- * local function my_error_handler(source, message, traceback)
495
- * print(source) --> lua
496
- * print(message) --> main/my.script:10: attempt to perform arithmetic on a string value
497
- * print(traceback) --> stack traceback:
498
- * --> main/test.script:10: in function 'boom'
499
- * --> main/test.script:15: in function <main/my.script:13>
500
- * end
501
- *
502
- * local function boom()
503
- * return 10 + "string"
504
- * end
505
- *
506
- * function init(self)
507
- * sys.set_error_handler(my_error_handler)
508
- * boom()
509
- * end
499
+ * ```ts
500
+ * // Install error handler that just prints the errors
501
+ * function my_error_handler(source, message, traceback) {
502
+ * print(source); //> lua
503
+ * print(message); //> main/my.script:10: attempt to perform arithmetic on a string value
504
+ * print(traceback); //> stack traceback:
505
+ * //> main/test.script:10: in function 'boom'
506
+ * //> main/test.script:15: in function <main/my.script:13>
507
+ * }
508
+ *
509
+ * function boom() {
510
+ * return 10 + "string";
511
+ * }
512
+ *
513
+ * export default defineScript({
514
+ * init() {
515
+ * sys.set_error_handler(my_error_handler);
516
+ * boom();
517
+ * },
518
+ * });
510
519
  * ```
511
520
  */
512
521
  function set_error_handler(error_handler: (source: unknown, message: unknown, traceback: unknown) => void): void;
@@ -519,9 +528,9 @@ declare global {
519
528
  *
520
529
  * @param frequency - target frequency. 60 for 60 fps
521
530
  * @example
522
- * ```lua
523
- * Setting the update frequency to 60 frames per second
524
- * sys.set_update_frequency(60)
531
+ * ```ts
532
+ * // Setting the update frequency to 60 frames per second
533
+ * sys.set_update_frequency(60);
525
534
  * ```
526
535
  */
527
536
  function set_update_frequency(frequency: number): void;
@@ -538,9 +547,9 @@ declare global {
538
547
  *
539
548
  * @param swap_interval - target swap interval.
540
549
  * @example
541
- * ```lua
542
- * Setting the swap intervall to swap every v-blank
543
- * sys.set_vsync_swap_interval(1)
550
+ * ```ts
551
+ * // Setting the swap intervall to swap every v-blank
552
+ * sys.set_vsync_swap_interval(1);
544
553
  * ```
545
554
  */
546
555
  function set_vsync_swap_interval(swap_interval: number): void;