Open lostfictions opened 2 years ago
holy moly, what a great write up!
as you may have noticed im on a bit of a hiatus on this project because of work, but i'm really thankful for such an in-depth analysis! hopefully i'll find some more time to work on it soon :)
BTW, i do know off the top of my head that getting import type
to work is like a 2 line change, so if you ever have some spare time... 😉
Hey there, thanks for writing this! I'm giving it a shot -- attempting to rewrite one of the Godot sample games -- and I'm impressed with how well it works already.
In the interests of documentation, one thing I think might be interesting is a comparison as to how it stacks up against GodotExplorer/ECMAScript (henceforth GE-ES). Here's a few things I'm noticing:
Math.sin()
orString.includes()
. ts2gd instead requires you to use GDScript equivalents. Fortunately, it provides quite thorough type definitions for them including docstrings, which eases the learning curve for users coming from JavaScript-land. GE-ES also supportsinstanceof
-- which performs narrowing in TypeScript -- while ts2gd appears to have no equivalent (though it could probably transpileinstanceof
to the GDScriptis
operator).@ts-ignore
s oras any
assertions, both of which are noisy and degrade both type safety and the editor experience. ts2gd has already worked around this with methods onVector2
/Vector3
instances; while it's slightly less ergonomic, it's typesafe. GE-ES could add such methods but has yet to do so.Promise
s andasync
/await
via Lua coroutines!)import type
, for example).