Daily Godot Tip #5: You can enable Add Type Hints in the editor settings to make auto generated code be spawned in with static typing
https://programming.dev/pictrs/image/934339f4-0423-4f8f-9871-57427ce52baa.webm
https://programming.dev/pictrs/image/934339f4-0423-4f8f-9871-57427ce52baa.webm
5 Comments
astrsk@kbin.run · 6 pts · 2y
This is a good tip. While it’s nice it’s automatic for templates it would be nice if I could enable a warning or even build error if I miss a type hint. I’ve started using them everywhere because it helps me when I’m going back through old code or code that hasn’t changed in a while. Especially helpful for debugging. As a recent typescript convert, I much prefer gdscript with type hints.
Adelphius@lemmy.world · 5 pts · 2y
You can do this on a per project basis.
Under Project Setting > General enable advanced settings.
Then under Debug > GDScript you can set your preferred settings for warning and error. I like these settings as it's more like a statically typed language:
astrsk@kbin.run · 2 pts · 2y
Oh fantastic thank you! I didn’t know they called it unsafe, which would explain why my search of settings didn’t come up with type hinting here. Much appreciated!
grrgyle@slrpnk.net · 5 pts · 2y
Very handy, thank you!
Binette@lemmy.ml · 1 pts · 2y
I remember it being enabled automatically at some point, but then it was removed. Or maybe I'm remembering it wrong