Better, faster GDScript through Static Typing

If you aren’t statically typing your GDScript… hey… it’s me… I’m emitting a signal for you to start doing that if you want better code for marginally more effort.

It’s hardly any more work, and it makes code that is:

  1. Easier to read

  2. Faster at runtime (a tiny bit)

  3. Plays nicer with autocomplete etc.

  4. More consistent

  5. Less buggy

I made a little video about why and how to get your project fully statically typed.

It might not be worth it for very small toy projects but larger projects will benefit. And it’s just a good habit.

So set UNTYPED_DECLARATION to WARN and start typing your stuff!

5 Likes

For Monkanics, I have UNTYPED_DECLARATION set to ERROR.

I agree with literally everything you said though. (Also, I like the wit in your writing)

Edit:

I’d also like to add that using this operator := will allow Godot to infer types and will bypass the UNTYPED_DECLARATION check. I only use this as a placeholder until I know what type a variable is.