-
Notifications
You must be signed in to change notification settings - Fork 52
CreateObject function call implies correct return type
#1154
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
Conversation
TwitchBronBron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not crazy about using a callback function on the TypedFunctionType class. Makes it harder to evaluate/inspect/reason about the type. And once this signature is there, it's going to be a breaking change to remove it if we need to redesign this feature/functionality in the future.
I'd much rather see proper overloading support implemented like they do in typescript, along with string literal value types. Something like this:
function createObject("roSGNode", "Label") as roSGNodeLabel
function createObject("roSGNode", "Rectangle") as roSGNodeRectangle
These would be auto-injected into the program when we define all the built-in types, and then we'd augment that list with the user-defined objects.
|
Ok. Hmmm. I don’t know about making support for overloading functions yet, so maybe I’ll change this so it’s just a special case, and does not change the interface/constructors for anything yet. |
…ng for Cretaeobject calls
TwitchBronBron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest changes feel much better, protects us a bit from breaking changes. Thanks!
Previously, everything returned from
createObjectwasObjectTypeNow, it looks at the arguments, and if passed string literals, it is able to infer either the built-in Component/Object or a custom component:
if the args are not string literals, it still just returns ObjectType....