Closed nmerget closed 1 month ago
Hi, I would also like the d.ts file to be generated correctly and I would be happy to help in archiving this. Currently, when I try to use this pr branch, I get around 218 missing declaration errors: `godot.d.ts:107978:50 - error TS2304: Cannot find name 'Transform3D'.
107978 set_pose(name: StringName | string, transform: Transform3D, linear_velocity: Vector3, angular_velocity: Vector3, tracking_confidence: XRPose.TrackingConfidence) : void;
godot.d.ts:108058:24 - error TS2304: Cannot find name 'Transform3D'.
108058 static world_origin: Transform3D;
godot.d.ts:108086:32 - error TS2304: Cannot find name 'Transform3D'.
108086 static get_hmd_transform() : Transform3D;
godot.d.ts:108095:29 - error TS2304: Cannot find name 'Dictionary'.
108095 static get_interfaces() : Dictionary[];
godot.d.ts:108098:34 - error TS2304: Cannot find name 'Transform3D'.
108098 static get_reference_frame() : Transform3D;
godot.d.ts:108119:31 - error TS2304: Cannot find name 'Transform3D'.
108119 static get_world_origin() : Transform3D;
godot.d.ts:108122:36 - error TS2304: Cannot find name 'Transform3D'.
108122 static set_world_origin(p_value: Transform3D) : void;
godot.d.ts:111135:36 - error TS2304: Cannot find name 'Dictionary'.
111135 static get_global_class_list() : Dictionary[];
[12:28:23 PM] Found 218 errors. Watching for file changes.`
And indeed, these types are not generated. Are they supposed to come from somewhere else or am I missing something?
I see Transform3D generated as Transform btw. But nothing like Dictionary.
@SebastianAtWork I played with this a bit and resolved the Transform3D and Dictionary issue.
Using this PR's branch:
You should be able to fix Transform3D by going into misc/godot.d.ts
and renaming the Transform
class symbol to Transform3D
For Dictionary
, it looks like that's supposed to resolve to object
for the final output, but *[]
breaks the type conversion.
In editor/editor_tools.cpp
, replace the function get_type_name
with this:
static String get_type_name(const String &p_type) {
if (p_type.is_empty() || p_type == "void")
return "void";
if (p_type.ends_with("[]")) {
String base_type = p_type.substr(0, p_type.length() - 2);
return "Array<" + get_type_name(base_type) + ">";
}
if (p_type == "int" || p_type == "float")
return "number";
if (p_type == "bool")
return "boolean";
if (p_type == "String" || p_type == "NodePath")
return "string";
if (p_type == "Array")
return "any[]";
if (p_type == "Dictionary")
return "object";
if (p_type == "Variant" || p_type.contains("*"))
return "any";
if (p_type == "StringName")
return "StringName | string";
return p_type;
}
godot.d.ts
file for version 4.1