Skip to content

Conversation

nmerget
Copy link
Collaborator

@nmerget nmerget commented Jan 20, 2024

  • fix issues with new generated godot.d.ts file for version 4.1

@nmerget nmerget linked an issue Jan 20, 2024 that may be closed by this pull request
@nmerget nmerget mentioned this pull request Jan 20, 2024
@nmerget nmerget marked this pull request as draft January 20, 2024 13:01
@SebastianAtWork
Copy link

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?

@SebastianAtWork
Copy link

SebastianAtWork commented Apr 14, 2024

I see Transform3D generated as Transform btw. But nothing like Dictionary.

@drwpwrs
Copy link

drwpwrs commented Aug 23, 2024

@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;
}

@nmerget nmerget marked this pull request as ready for review September 15, 2024 08:04
@nmerget nmerget merged commit 72c366d into master Sep 15, 2024
14 checks passed
@nmerget nmerget deleted the fix-generating-declaration-file branch September 21, 2024 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Property 'Sprite2D' does not exist on type 'typeof godot' - Missing from godot.d.ts ? .d.ts file has errors
3 participants