Extending type - Trouble getting a table union to resolve / autocomplete (self, generics, and recursion) #1846
Unanswered
DeveloperBlue
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a type
BaseTypethat represent a table with properties. I want to create a subtype that extends that with additional properties. Both type and subtype also take the same generic. I've run into some issues with implementation:Repro code below.
The
selfvariable and themyHandlervariable should have the same typeFinalType<MyExtensionSpecificModel>but both seem to resolve differently.Autocomplete for
myHandlerworks butselfdoes not. If I correctly call a function e.g.self:baseFnOne(model), the checker does not throw an error. But if I try to call a function that doesn't exist, or pass the wrong number or type of arguments, the checker throws a large verbose error on the entire variable. It seems to know what functions I can call, and what parameters they require, but won't autocomplete that or display that when I hoverself(just resolves toself: a)Interestingly, I can see the correct type resolution when hovering
myHandler.It sees all the expected functions; they all resolve correctly and its very readable.
Expand for screenshots
Autocomplete (self vs myHandler)
Autocomplete and resolution working fine, expected behavior (using

myHandler)look ma, all our properties from the unioned table, resolving nicely!
Autocomplete not working (using

self)Missing arguments (self vs myHandler)
a more targeted message for missing argument (using

myHandler)Verbose mess for missing argument, thrown on the entire variable (using

self)Am I just approaching this wrong?
Code
Mainly I just want to extend a table of functions while keeping self as a reference to that same extended table. (and pass my generics in and keep typesafety and autocomplete)
Beta Was this translation helpful? Give feedback.
All reactions