Skip to content

Commit be2c73c

Browse files
feat: UserTypeDescriptor resource type safety
1 parent b96f13a commit be2c73c

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@godot-js/editor": patch
3+
---
4+
5+
**Types:** `UserTypeDescriptor` `resource` property is now type-safe and will auto-complete, accepting `Script` resources.

scripts/jsb.editor/src/jsb.editor.codegen.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import type {
2+
ExtractValueKeys,
23
FileAccess,
34
GArray,
45
GDictionary,
56
GReadProxyValueWrap,
67
Node,
78
PropertyInfo,
89
Resource,
10+
ResourceTypes,
11+
Script,
912
Variant,
1013
} from "godot";
1114

@@ -1136,7 +1139,7 @@ export type UserTypeDescriptor = GDictionary<{
11361139
/**
11371140
* res:// style path to the TypeScript module where this type is exported.
11381141
*/
1139-
resource: string;
1142+
resource: ExtractValueKeys<ResourceTypes, Script>;
11401143
/**
11411144
* Preferred type name to use when importing.
11421145
*/

scripts/typings/godot.generated.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ declare module "godot" {
88

99
class Node<Map extends Record<string, Node> = any> extends Object { }
1010
class Resource { }
11+
class Script extends Resource { }
12+
interface ResourceTypes { }
13+
1114
class GArray<T = any> {
1215
static create<T>(elements: [T] extends [GArray<infer E>] ? Array<E | GProxyValueWrap<E>> : Array<T | GProxyValueWrap<T>>):
1316
[T] extends [GArray<infer E>]

0 commit comments

Comments
 (0)