-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
utility function import #66
Comments
To clarify, this issue is related to #61 right? Because before that |
Ahh, yeah I tested it on that branch first, put it also happens on main (without the default). |
I think in this case # A.gd
static func utilFunc():
print("util") # B.gd
extends Node
const A = preload("res://A.gd")
static func _ready():
A.utilFunc() |
This is obviously an error today so we should probably emit an error for now, rather than just incorrect code. :) But I disagree that this should be an error for all time. It's a very convenient pattern in TS to export and import top-level functions and variables, so if we can make it work somehow, I think we should try to. One idea I had for this case was to gather up all top-level declarations into a new class and make that class an autoload. e.g. util.ts:
generates UtilAutoload.gd
Then I know this kinda goes against the principle of 'simplest possible emit' but it is such a handy thing to do in TS that I wouldn't want to disallow people from doing it. |
Given a file util.ts with
and a file Actors.ts with
The generated util.gd file will be empty and only have the comment:
The Actor.gd file will look like:
The text was updated successfully, but these errors were encountered: