CreateObject function call implies correct return type#1154
Conversation
TwitchBronBron
left a comment
There was a problem hiding this comment.
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.
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....