@defold-typescript/types 0.31.0 → 0.32.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.
@@ -349,14 +349,14 @@
349
349
  "camera\u0000FUNCTION\u0000camera.set_orthographic_mode\u0000[{\"types\":[\"nil\",\"number\",\"url\"],\"isOptional\":false},{\"types\":[\"number\"],\"isOptional\":false}]->[]": "function set_orthographic_mode(camera: Url | number | undefined, mode: number): void;",
350
350
  "camera\u0000FUNCTION\u0000camera.set_orthographic_zoom\u0000[{\"types\":[\"nil\",\"number\",\"url\"],\"isOptional\":false},{\"types\":[\"number\"],\"isOptional\":false}]->[]": "function set_orthographic_zoom(camera: Url | number | undefined, orthographic_zoom: number): void;",
351
351
  "camera\u0000FUNCTION\u0000camera.world_to_screen\u0000[{\"types\":[\"vector3\"],\"isOptional\":false},{\"types\":[\"nil\",\"number\",\"url\"],\"isOptional\":true}]->[{\"types\":[\"vector3\"],\"isOptional\":false}]": "function world_to_screen(world_pos: Vector3, camera?: Url | number): Vector3;",
352
- "camera\u0000PROPERTY\u0000aspect_ratio\u0000": "aspect_ratio: unknown;",
353
- "camera\u0000PROPERTY\u0000far_z\u0000": "far_z: unknown;",
354
- "camera\u0000PROPERTY\u0000fov\u0000": "fov: unknown;",
355
- "camera\u0000PROPERTY\u0000near_z\u0000": "near_z: unknown;",
356
- "camera\u0000PROPERTY\u0000orthographic_auto_zoom\u0000": "orthographic_auto_zoom: unknown;",
357
- "camera\u0000PROPERTY\u0000orthographic_zoom\u0000": "orthographic_zoom: unknown;",
358
- "camera\u0000PROPERTY\u0000projection\u0000": "projection: unknown;",
359
- "camera\u0000PROPERTY\u0000view\u0000": "view: unknown;",
352
+ "camera\u0000PROPERTY\u0000aspect_ratio\u0000": "aspect_ratio: number;",
353
+ "camera\u0000PROPERTY\u0000far_z\u0000": "far_z: number;",
354
+ "camera\u0000PROPERTY\u0000fov\u0000": "fov: number;",
355
+ "camera\u0000PROPERTY\u0000near_z\u0000": "near_z: number;",
356
+ "camera\u0000PROPERTY\u0000orthographic_auto_zoom\u0000": "orthographic_auto_zoom: number;",
357
+ "camera\u0000PROPERTY\u0000orthographic_zoom\u0000": "orthographic_zoom: number;",
358
+ "camera\u0000PROPERTY\u0000projection\u0000": "projection: Matrix4;",
359
+ "camera\u0000PROPERTY\u0000view\u0000": "view: Matrix4;",
360
360
  "collectionfactory\u0000CONSTANT\u0000collectionfactory.STATUS_LOADED\u0000": "const STATUS_LOADED: number & { readonly __brand: \"collectionfactory.STATUS_LOADED\" };",
361
361
  "collectionfactory\u0000CONSTANT\u0000collectionfactory.STATUS_LOADING\u0000": "const STATUS_LOADING: number & { readonly __brand: \"collectionfactory.STATUS_LOADING\" };",
362
362
  "collectionfactory\u0000CONSTANT\u0000collectionfactory.STATUS_UNLOADED\u0000": "const STATUS_UNLOADED: number & { readonly __brand: \"collectionfactory.STATUS_UNLOADED\" };",
@@ -1168,7 +1168,7 @@
1168
1168
  "sprite\u0000FUNCTION\u0000sprite.set_vflip\u0000[{\"types\":[\"hash\",\"string\",\"url\"],\"isOptional\":false},{\"types\":[\"boolean\"],\"isOptional\":false}]->[]": "function set_vflip(url: string | Hash | Url, flip: boolean): void;",
1169
1169
  "sprite\u0000PROPERTY\u0000animation\u0000": "animation: Hash;",
1170
1170
  "sprite\u0000PROPERTY\u0000cursor\u0000": "cursor: number;",
1171
- "sprite\u0000PROPERTY\u0000frame_count\u0000": "frame_count: Hash;",
1171
+ "sprite\u0000PROPERTY\u0000frame_count\u0000": "frame_count: number;",
1172
1172
  "sprite\u0000PROPERTY\u0000image\u0000": "image: Hash;",
1173
1173
  "sprite\u0000PROPERTY\u0000material\u0000": "material: Hash;",
1174
1174
  "sprite\u0000PROPERTY\u0000playback_rate\u0000": "playback_rate: number;",
@@ -1661,14 +1661,14 @@
1661
1661
  "camera\u0000FUNCTION\u0000camera.set_orthographic_mode\u0000[{\"types\":[\"nil\",\"number\",\"url\"],\"isOptional\":false},{\"types\":[\"number\"],\"isOptional\":false}]->[]": "function set_orthographic_mode(camera: Url | number | undefined, mode: number): void;",
1662
1662
  "camera\u0000FUNCTION\u0000camera.set_orthographic_zoom\u0000[{\"types\":[\"nil\",\"number\",\"url\"],\"isOptional\":false},{\"types\":[\"number\"],\"isOptional\":false}]->[]": "function set_orthographic_zoom(camera: Url | number | undefined, orthographic_zoom: number): void;",
1663
1663
  "camera\u0000FUNCTION\u0000camera.world_to_screen\u0000[{\"types\":[\"vector3\"],\"isOptional\":false},{\"types\":[\"nil\",\"number\",\"url\"],\"isOptional\":true}]->[{\"types\":[\"vector3\"],\"isOptional\":false}]": "function world_to_screen(world_pos: Vector3, camera?: Url | number): Vector3;",
1664
- "camera\u0000PROPERTY\u0000aspect_ratio\u0000": "aspect_ratio: unknown;",
1665
- "camera\u0000PROPERTY\u0000far_z\u0000": "far_z: unknown;",
1666
- "camera\u0000PROPERTY\u0000fov\u0000": "fov: unknown;",
1667
- "camera\u0000PROPERTY\u0000near_z\u0000": "near_z: unknown;",
1668
- "camera\u0000PROPERTY\u0000orthographic_auto_zoom\u0000": "orthographic_auto_zoom: unknown;",
1669
- "camera\u0000PROPERTY\u0000orthographic_zoom\u0000": "orthographic_zoom: unknown;",
1670
- "camera\u0000PROPERTY\u0000projection\u0000": "projection: unknown;",
1671
- "camera\u0000PROPERTY\u0000view\u0000": "view: unknown;",
1664
+ "camera\u0000PROPERTY\u0000aspect_ratio\u0000": "aspect_ratio: number;",
1665
+ "camera\u0000PROPERTY\u0000far_z\u0000": "far_z: number;",
1666
+ "camera\u0000PROPERTY\u0000fov\u0000": "fov: number;",
1667
+ "camera\u0000PROPERTY\u0000near_z\u0000": "near_z: number;",
1668
+ "camera\u0000PROPERTY\u0000orthographic_auto_zoom\u0000": "orthographic_auto_zoom: number;",
1669
+ "camera\u0000PROPERTY\u0000orthographic_zoom\u0000": "orthographic_zoom: number;",
1670
+ "camera\u0000PROPERTY\u0000projection\u0000": "projection: Matrix4;",
1671
+ "camera\u0000PROPERTY\u0000view\u0000": "view: Matrix4;",
1672
1672
  "collectionfactory\u0000CONSTANT\u0000collectionfactory.STATUS_LOADED\u0000": "const STATUS_LOADED: number & { readonly __brand: \"collectionfactory.STATUS_LOADED\" };",
1673
1673
  "collectionfactory\u0000CONSTANT\u0000collectionfactory.STATUS_LOADING\u0000": "const STATUS_LOADING: number & { readonly __brand: \"collectionfactory.STATUS_LOADING\" };",
1674
1674
  "collectionfactory\u0000CONSTANT\u0000collectionfactory.STATUS_UNLOADED\u0000": "const STATUS_UNLOADED: number & { readonly __brand: \"collectionfactory.STATUS_UNLOADED\" };",
@@ -2479,7 +2479,7 @@
2479
2479
  "sprite\u0000FUNCTION\u0000sprite.set_vflip\u0000[{\"types\":[\"hash\",\"string\",\"url\"],\"isOptional\":false},{\"types\":[\"boolean\"],\"isOptional\":false}]->[]": "function set_vflip(url: string | Hash | Url, flip: boolean): void;",
2480
2480
  "sprite\u0000PROPERTY\u0000animation\u0000": "animation: Hash;",
2481
2481
  "sprite\u0000PROPERTY\u0000cursor\u0000": "cursor: number;",
2482
- "sprite\u0000PROPERTY\u0000frame_count\u0000": "frame_count: Hash;",
2482
+ "sprite\u0000PROPERTY\u0000frame_count\u0000": "frame_count: number;",
2483
2483
  "sprite\u0000PROPERTY\u0000image\u0000": "image: Hash;",
2484
2484
  "sprite\u0000PROPERTY\u0000material\u0000": "material: Hash;",
2485
2485
  "sprite\u0000PROPERTY\u0000playback_rate\u0000": "playback_rate: number;",
@@ -3489,7 +3489,7 @@
3489
3489
  "sprite\u0000FUNCTION\u0000sprite.set_vflip\u0000[{\"types\":[\"hash\",\"string\",\"url\"],\"isOptional\":false},{\"types\":[\"boolean\"],\"isOptional\":false}]->[]": "function set_vflip(url: string | Hash | Url, flip: boolean): void;",
3490
3490
  "sprite\u0000PROPERTY\u0000animation\u0000": "animation: Hash;",
3491
3491
  "sprite\u0000PROPERTY\u0000cursor\u0000": "cursor: number;",
3492
- "sprite\u0000PROPERTY\u0000frame_count\u0000": "frame_count: Hash;",
3492
+ "sprite\u0000PROPERTY\u0000frame_count\u0000": "frame_count: number;",
3493
3493
  "sprite\u0000PROPERTY\u0000image\u0000": "image: Hash;",
3494
3494
  "sprite\u0000PROPERTY\u0000material\u0000": "material: Hash;",
3495
3495
  "sprite\u0000PROPERTY\u0000playback_rate\u0000": "playback_rate: number;",
@@ -257,44 +257,44 @@ declare global {
257
257
  * projection of a perspective camera.
258
258
  * The type of the property is number.
259
259
  */
260
- aspect_ratio: unknown;
260
+ aspect_ratio: number;
261
261
  /**
262
262
  * Camera frustum far plane.
263
263
  * The type of the property is float.
264
264
  */
265
- far_z: unknown;
265
+ far_z: number;
266
266
  /**
267
267
  * Vertical field of view of the camera.
268
268
  * The type of the property is float.
269
269
  */
270
- fov: unknown;
270
+ fov: number;
271
271
  /**
272
272
  * Camera frustum near plane.
273
273
  * The type of the property is float.
274
274
  */
275
- near_z: unknown;
275
+ near_z: number;
276
276
  /**
277
277
  * READ ONLY The zoom calculated from the current window and project dimensions
278
278
  * in auto fit and auto cover modes. The value is 1.0 in fixed mode.
279
279
  * The type of the property is float.
280
280
  */
281
- orthographic_auto_zoom: unknown;
281
+ orthographic_auto_zoom: number;
282
282
  /**
283
283
  * Positive zoom multiplier when using an orthographic projection. In auto fit and auto cover
284
284
  * modes, this value is multiplied with the calculated orthographic_auto_zoom value.
285
285
  * The type of the property is float.
286
286
  */
287
- orthographic_zoom: unknown;
287
+ orthographic_zoom: number;
288
288
  /**
289
289
  * READ ONLY The calculated projection matrix of the camera.
290
290
  * The type of the property is matrix4.
291
291
  */
292
- projection: unknown;
292
+ projection: Matrix4;
293
293
  /**
294
294
  * READ ONLY The calculated view matrix of the camera.
295
295
  * The type of the property is matrix4.
296
296
  */
297
- view: unknown;
297
+ view: Matrix4;
298
298
  }
299
299
  }
300
300
  }
@@ -44,6 +44,7 @@ import "../vmath";
44
44
  import "../webview";
45
45
  import "../window";
46
46
  import "../zlib";
47
+ import "../../src/custom-messages";
47
48
  import "../../src/engine-globals";
48
49
  import "../../src/go-overloads";
49
50
  import "../../src/message-guard";
@@ -44,6 +44,7 @@ import "../vmath";
44
44
  import "../webview";
45
45
  import "../window";
46
46
  import "../zlib";
47
+ import "../../src/custom-messages";
47
48
  import "../../src/engine-globals";
48
49
  import "../../src/go-overloads";
49
50
  import "../../src/message-guard";
@@ -44,6 +44,7 @@ import "../vmath";
44
44
  import "../webview";
45
45
  import "../window";
46
46
  import "../zlib";
47
+ import "../../src/custom-messages";
47
48
  import "../../src/engine-globals";
48
49
  import "../../src/go-overloads";
49
50
  import "../../src/message-guard";
@@ -120,7 +120,7 @@ declare global {
120
120
  /**
121
121
  * READ ONLY The frame count of the currently playing animation.
122
122
  */
123
- frame_count: Hash;
123
+ frame_count: number;
124
124
  /**
125
125
  * The image used when rendering the sprite. The type of the property is hash.
126
126
  */
@@ -106,7 +106,7 @@ declare global {
106
106
  /**
107
107
  * READ ONLY The frame count of the currently playing animation.
108
108
  */
109
- frame_count: Hash;
109
+ frame_count: number;
110
110
  /**
111
111
  * The image used when rendering the sprite. The type of the property is hash.
112
112
  */
@@ -257,44 +257,44 @@ declare global {
257
257
  * projection of a perspective camera.
258
258
  * The type of the property is number.
259
259
  */
260
- aspect_ratio: unknown;
260
+ aspect_ratio: number;
261
261
  /**
262
262
  * Camera frustum far plane.
263
263
  * The type of the property is float.
264
264
  */
265
- far_z: unknown;
265
+ far_z: number;
266
266
  /**
267
267
  * Vertical field of view of the camera.
268
268
  * The type of the property is float.
269
269
  */
270
- fov: unknown;
270
+ fov: number;
271
271
  /**
272
272
  * Camera frustum near plane.
273
273
  * The type of the property is float.
274
274
  */
275
- near_z: unknown;
275
+ near_z: number;
276
276
  /**
277
277
  * READ ONLY The zoom calculated from the current window and project dimensions
278
278
  * in auto fit and auto cover modes. The value is 1.0 in fixed mode.
279
279
  * The type of the property is float.
280
280
  */
281
- orthographic_auto_zoom: unknown;
281
+ orthographic_auto_zoom: number;
282
282
  /**
283
283
  * Positive zoom multiplier when using an orthographic projection. In auto fit and auto cover
284
284
  * modes, this value is multiplied with the calculated orthographic_auto_zoom value.
285
285
  * The type of the property is float.
286
286
  */
287
- orthographic_zoom: unknown;
287
+ orthographic_zoom: number;
288
288
  /**
289
289
  * READ ONLY The calculated projection matrix of the camera.
290
290
  * The type of the property is matrix4.
291
291
  */
292
- projection: unknown;
292
+ projection: Matrix4;
293
293
  /**
294
294
  * READ ONLY The calculated view matrix of the camera.
295
295
  * The type of the property is matrix4.
296
296
  */
297
- view: unknown;
297
+ view: Matrix4;
298
298
  }
299
299
  }
300
300
  }
@@ -120,7 +120,7 @@ declare global {
120
120
  /**
121
121
  * READ ONLY The frame count of the currently playing animation.
122
122
  */
123
- frame_count: Hash;
123
+ frame_count: number;
124
124
  /**
125
125
  * The image used when rendering the sprite. The type of the property is hash.
126
126
  */
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="lua-types/5.1" />
2
2
  /// <reference types="lua-types/special/jit-only" />
3
3
  import "./generated/builtin-messages";
4
+ import "./src/custom-messages";
4
5
  import "./src/msg-overloads";
5
6
  import "./src/message-guard";
6
7
  import "./src/window-event-guard";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defold-typescript/types",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "TypeScript types for the Defold engine's Lua APIs.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/scripts/regen.ts CHANGED
@@ -546,6 +546,7 @@ export function kindStdlibReferences(entry: KindManifestEntry): string {
546
546
 
547
547
  const UNIVERSAL_EXTRA_IMPORTS: readonly string[] = [
548
548
  "../builtin-messages",
549
+ "../../src/custom-messages",
549
550
  "../../src/engine-globals",
550
551
  "../../src/msg-overloads",
551
552
  "../../src/message-guard",
package/src/core-types.ts CHANGED
@@ -152,8 +152,7 @@ declare const OpaqueBrand: unique symbol;
152
152
  * The handle kinds modeled today:
153
153
  * - GUI & rendering: `Opaque<"node">`, `Opaque<"texture">`,
154
154
  * `Opaque<"render_target">`, `Opaque<"constant">`, `Opaque<"constant_buffer">`
155
- * - Resources & buffers: `Opaque<"resource">`, `Opaque<"buffer">`,
156
- * `Opaque<"bufferstream">`
155
+ * - Buffers: `Opaque<"buffer">`, `Opaque<"bufferstream">`
157
156
  * - Sockets: `Opaque<"client">`, `Opaque<"server">`, `Opaque<"master">`,
158
157
  * `Opaque<"connected">`, `Opaque<"unconnected">`
159
158
  * - Box2D physics: `Opaque<"b2Body">`, `Opaque<"b2World">`
@@ -193,6 +192,7 @@ export const DEFOLD_TYPE_MAP: Readonly<Record<string, string>> = {
193
192
  number: "number",
194
193
  int: "number",
195
194
  integer: "number",
195
+ float: "number",
196
196
  string: "string",
197
197
  boolean: "boolean",
198
198
  table: "Record<string | number, unknown>",
@@ -218,6 +218,9 @@ export const DEFOLD_TYPE_MAP: Readonly<Record<string, string>> = {
218
218
  buffer: 'Opaque<"buffer">',
219
219
  bufferstream: 'Opaque<"bufferstream"> & { [index: number]: number }',
220
220
  userdata: 'Opaque<"userdata">',
221
+ // Vocabulary, not a shipped brand: no current ref-doc fixture types a slot
222
+ // `resource`, so nothing hand-written may name `Opaque<"resource">`. Kept so a
223
+ // future upstream slot carrying the token emits a handle rather than `unknown`.
221
224
  resource: 'Opaque<"resource">',
222
225
  b2World: 'Opaque<"b2World">',
223
226
  b2Body: 'Opaque<"b2Body">',
@@ -0,0 +1,54 @@
1
+ /** @noSelfInFile */
2
+
3
+ declare global {
4
+ /**
5
+ * A project's own message ids, mapped to the payload each carries. Empty as
6
+ * shipped and extended by declaration merging in your own code:
7
+ *
8
+ * ```ts
9
+ * declare global {
10
+ * interface CustomMessages {
11
+ * spawn_wave: { count: number; boss?: boolean };
12
+ * }
13
+ * }
14
+ *
15
+ * export {};
16
+ * ```
17
+ *
18
+ * The `export {};` makes the file a module, which `declare global` requires;
19
+ * drop it only in a file that already imports or exports something.
20
+ *
21
+ * Once declared, an id is checked on `msg.post` and narrowed by `isMessage`
22
+ * and `onMessage` exactly like a built-in one. Augment this interface rather
23
+ * than `BuiltinMessages`, which is regenerated from the Defold reference docs
24
+ * and reserved for the ids the engine itself defines.
25
+ */
26
+ interface CustomMessages {}
27
+
28
+ /**
29
+ * Every message id with a declared payload: the engine's, plus your own.
30
+ *
31
+ * The custom half is intersected with `string` because a numeric key is one
32
+ * the lowering cannot emit — `onMessage`'s handler names become `hash(...)`
33
+ * comparisons, and only an identifier or a string literal survives that — so
34
+ * offering it would type-check a handler that silently never runs.
35
+ */
36
+ type MessageId = BuiltinMessageId | (keyof CustomMessages & string);
37
+
38
+ // A built-in id is tested first, so a `CustomMessages` key shadowing one is
39
+ // inert rather than silently re-typing an engine message. Resolving to the
40
+ // intersection instead would yield an unsatisfiable payload and point the
41
+ // diagnostic at the call site rather than the declaration.
42
+ /**
43
+ * The payload declared for a message id: its `BuiltinMessages` entry, else
44
+ * its `CustomMessages` entry, else the open record an undeclared id keeps.
45
+ * An id declared in both resolves to the built-in payload.
46
+ */
47
+ type MessagePayload<K> = K extends BuiltinMessageId
48
+ ? BuiltinMessages[K]
49
+ : K extends keyof CustomMessages
50
+ ? CustomMessages[K]
51
+ : Record<string | number, unknown>;
52
+ }
53
+
54
+ export {};
package/src/emit-dts.ts CHANGED
@@ -240,6 +240,54 @@ export const RETURN_TYPE_OVERRIDES: ReadonlyMap<string, string> = new Map([
240
240
  ["editor.tx.add", 'Opaque<"transaction_step">'],
241
241
  ]);
242
242
 
243
+ // A property whose upstream `<span class="type">` states a type the engine does
244
+ // not use. Unlike every other override here, which fills a gap upstream left
245
+ // empty, these contradict a token upstream explicitly declares — so each entry
246
+ // records that token and `property-correction-provenance.test.ts` pins it
247
+ // against every vendored ref-doc. The day upstream corrects a span the suite
248
+ // reds and the entry is deleted rather than silently overriding a value that
249
+ // had since become right.
250
+ //
251
+ // Demonstrated errors only. A property whose declared type is merely imprecise
252
+ // — every `resource.*` path hash, say — is not a correction candidate.
253
+ export interface PropertyTypeCorrection {
254
+ readonly ts: string;
255
+ readonly upstream: string;
256
+ readonly reason: string;
257
+ }
258
+
259
+ // Keyed `<namespace>.<property>`, so a same-named property in another catalog
260
+ // is untouched.
261
+ export const PROPERTY_TYPE_CORRECTIONS: ReadonlyMap<string, PropertyTypeCorrection> = new Map([
262
+ [
263
+ "sprite.frame_count",
264
+ {
265
+ ts: "number",
266
+ upstream: "hash",
267
+ reason:
268
+ "a count of animation frames, which the prose confirms; `hash` is a copy-paste of the sibling animation-id spans",
269
+ },
270
+ ],
271
+ [
272
+ "camera.projection",
273
+ {
274
+ ts: "Matrix4",
275
+ upstream: "float",
276
+ reason:
277
+ "the prose in the same element says matrix4; every camera property carries the same blanket `float` span",
278
+ },
279
+ ],
280
+ [
281
+ "camera.view",
282
+ {
283
+ ts: "Matrix4",
284
+ upstream: "float",
285
+ reason:
286
+ "the prose in the same element says matrix4; every camera property carries the same blanket `float` span",
287
+ },
288
+ ],
289
+ ]);
290
+
243
291
  // FQN-keyed allowlist of the `types.is_*` checks that genuinely narrow their
244
292
  // argument, mapped to the `DEFOLD_TYPE_MAP` token whose interface they prove.
245
293
  // Emitting these as user-defined type guards (`var_ is Vector3`) is the only way
@@ -1641,7 +1689,7 @@ export function emitDeclarations(module: ApiModule, options?: EmitOptions): stri
1641
1689
  for (const docLine of summaryDocLines(p.brief, p.description, `${INDENT}${INDENT}`)) {
1642
1690
  lines.push(docLine);
1643
1691
  }
1644
- lines.push(`${INDENT}${INDENT}${emitPropertyMember(p, mapType)}`);
1692
+ lines.push(`${INDENT}${INDENT}${emitPropertyMember(p, mapType, module.namespace)}`);
1645
1693
  }
1646
1694
  lines.push(`${INDENT}}`);
1647
1695
  }
@@ -1759,7 +1807,7 @@ export function emitSymbolSignatures(module: ApiModule, options?: EmitOptions):
1759
1807
  for (const p of module.properties) {
1760
1808
  out.push({
1761
1809
  identity: { namespace: module.namespace, kind: "PROPERTY", name: p.name, signature: "" },
1762
- tsSignature: emitPropertyMember(p, mapType),
1810
+ tsSignature: emitPropertyMember(p, mapType, module.namespace),
1763
1811
  });
1764
1812
  }
1765
1813
 
@@ -2224,9 +2272,19 @@ function emitReturn(
2224
2272
  return { type: ts, trailing: "" };
2225
2273
  }
2226
2274
 
2227
- function emitPropertyMember(p: ApiProperty, mapType: (t: string) => string): string {
2275
+ function emitPropertyMember(
2276
+ p: ApiProperty,
2277
+ mapType: (t: string) => string,
2278
+ namespace: string,
2279
+ ): string {
2228
2280
  const key = TS_IDENTIFIER.test(p.name) ? p.name : JSON.stringify(p.name);
2229
- const ts = p.types.length > 0 ? unionFromTokens(p.types, mapType) : "unknown";
2281
+ const correction = PROPERTY_TYPE_CORRECTIONS.get(`${namespace}.${p.name}`);
2282
+ const ts =
2283
+ correction !== undefined
2284
+ ? correction.ts
2285
+ : p.types.length > 0
2286
+ ? unionFromTokens(p.types, mapType)
2287
+ : "unknown";
2230
2288
  return `${key}: ${ts};`;
2231
2289
  }
2232
2290
 
@@ -26,9 +26,9 @@ declare global {
26
26
  * that lives only in the type system and is erased at transpile; because the
27
27
  * symbol is not exported, consumer code cannot fabricate one. The kinds
28
28
  * modeled: `node`, `texture`, `render_target`, `constant`, `constant_buffer`,
29
- * `resource`, `buffer`, `bufferstream`, `client`, `server`, `master`,
30
- * `connected`, `unconnected`, `b2Body`, `b2World`, `userdata`. You obtain them
31
- * from the engine, e.g. `gui.get_node("id")`, `render.render_target(...)`,
29
+ * `buffer`, `bufferstream`, `client`, `server`, `master`, `connected`,
30
+ * `unconnected`, `b2Body`, `b2World`, `userdata`. You obtain them from the
31
+ * engine, e.g. `gui.get_node("id")`, `render.render_target(...)`,
32
32
  * `render.constant_buffer()`, `resource.load_buffer(path)`, `b2d.get_world()`,
33
33
  * or `socket.tcp()`. See {@link Core.Opaque} for the full explanation, the per
34
34
  * -kind obtain examples, and the contrast with a `LuaTable` alias.
@@ -1,6 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
 
3
- import type { Hash, Opaque, Quaternion, Url, Vector3, Vector4 } from "./core-types";
3
+ import type { Hash, Quaternion, Url, Vector3, Vector4 } from "./core-types";
4
4
 
5
5
  interface ScriptProperty<TValue> {
6
6
  readonly __defoldScriptProperty: TValue;
@@ -46,7 +46,7 @@ declare global {
46
46
  url: SceneAddress | Hash | Url,
47
47
  property: string | Hash,
48
48
  options?: GoPropertyOptions,
49
- ): number | boolean | Hash | Url | Vector3 | Vector4 | Quaternion | Opaque<"resource">;
49
+ ): number | boolean | Hash | Url | Vector3 | Vector4 | Quaternion;
50
50
  /**
51
51
  * sets a named property of the specified game object or component, or a material constant
52
52
  *
@@ -80,7 +80,7 @@ declare global {
80
80
  function set(
81
81
  url: SceneAddress | Hash | Url,
82
82
  property: string | Hash,
83
- value: number | boolean | Hash | Url | Vector3 | Vector4 | Quaternion | Opaque<"resource">,
83
+ value: number | boolean | Hash | Url | Vector3 | Vector4 | Quaternion,
84
84
  options?: GoPropertyOptions,
85
85
  ): void;
86
86
  /**
@@ -119,7 +119,5 @@ declare global {
119
119
  function property(name: string, value: Vector4): ScriptProperty<Vector4>;
120
120
  /** @deprecated Declare quaternions via the `defineScript({ properties })` field. */
121
121
  function property(name: string, value: Quaternion): ScriptProperty<Quaternion>;
122
- /** @deprecated Declare resources via the `defineScript({ properties })` field. */
123
- function property(name: string, value: Opaque<"resource">): ScriptProperty<Opaque<"resource">>;
124
122
  }
125
123
  }
@@ -33,7 +33,7 @@ declare global {
33
33
  */
34
34
  function onMessage<TSelf = Record<never, never>>(
35
35
  handlers: Partial<{
36
- [K in BuiltinMessageId]: (self: TSelf, message: BuiltinMessages[K], sender: Url) => void;
36
+ [K in MessageId]: (self: TSelf, message: MessagePayload<K>, sender: Url) => void;
37
37
  }>,
38
38
  ): (
39
39
  self: TSelf,
@@ -27,9 +27,9 @@ declare global {
27
27
  * }
28
28
  * ```
29
29
  */
30
- function isMessage<K extends BuiltinMessageId>(
30
+ function isMessage<K extends MessageId>(
31
31
  message_id: Hash,
32
32
  message: Record<string | number, unknown>,
33
33
  expected: K,
34
- ): message is BuiltinMessages[K];
34
+ ): message is MessagePayload<K>;
35
35
  }
@@ -1,10 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
  import type { Hash, Url } from "./core-types";
3
3
 
4
- type MsgPostPayload<K> = K extends BuiltinMessageId
5
- ? BuiltinMessages[K]
6
- : Record<string | number, unknown>;
7
-
8
4
  declare global {
9
5
  namespace msg {
10
6
  /**
@@ -33,7 +29,7 @@ declare global {
33
29
  function post<K extends string>(
34
30
  receiver: SceneAddress | Url | Hash,
35
31
  message_id: K,
36
- message?: MsgPostPayload<K>,
32
+ message?: MessagePayload<K>,
37
33
  ): void;
38
34
  function post(
39
35
  receiver: SceneAddress | Url | Hash,