Add static typing to all properties #57
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happened?
I've just enabled enforcing static typing in my project, because I do like to see errors when I miss typing my variables. However, most of the variables in this plugin are completely untyped, so I was left with tens of errors to "fix".
It is a bit tricky to track down the root of these errors since they do come from an addon, so they appear with
gdscript://
with a strange ID instead of a traceableres://
path.I added static typing to every single variable and changed all of the paths to use this format:
@onready var name: Type = $Path/To/Node as Type
. It was a bit tedious, and since I do plan to use this addon and future versions in future projects, I would love if the addon could have strict static typing enforced already.plugin.gd
seemed to be the biggest culprit with all of its paths and variables. The things that should be typed are:var name: Type
(andas Type
if necessary)func name(parameter: Type) -> Type:
Aside from static typing, unsafe property access should also be fixed (Like setting the
position
of aNode
which might be aNode2D
but you don't know if it is).If you do plan to do this, you can check if it's been done correctly by enabling these settings:

Thanks for reaching the bottom and please ease the suffering of us static typers. :)
Version
1.3.1
Godot Version
4.2.1
Exact steps to reproduce this error
Simply enable these settings and you'll get the same errors each time you reload the project:
GDScript
Godot output
Additional information
cough cough
It's dusty down here.
Checks
Huh i thought i already did do that but will fix that soon! thanks for reporting :)
"Soon" i said... Will make some time to fix all gh issues and some more next week. I promise
No problemo!
okay i think i fixed it but i didn't get by far as many errors as you. I made everything static i may send you the update early to test it. Also thank you for showing me these settings these are very helpful! I like to type static too but forget it often..
ADDON-Discord-RPC-Godot.zip
try it whenever you have time for it
While the RPC is working 100%, the errors still seem to be there. It looks like there are only a few stray untyped variables left.

Checking the changes in github, and it looks to be a script in Debug.tscn:

The red is my version, which was static-typing-error-free.
weird i dont get these errors somehow but will fix them
will be in future updates