Closed samchon closed 5 years ago
Converting functions to return primitive objects, through Driver<Controller>
, has implemented. You can enjoy the benefit since the v0.2.1 patch. From now on, the Driver<Feature>
type, you can see from the above example code, can be come true.
However, I think that the mission has not been completed yet. To avoid domain error of TypeScript compiler, I'd to implement the primitive converter to adapt detour method allowing vulnerable and duplicated code. In such reason, I've published an issue on the TypeScript repository and this issue would be closed after the issue has been resolved.
TypeScript says it's the regular spec. Therefore, I consider that this issue has been fixed.
TGrid has adopted
JSON
structure on network communication.Therefore, when calling a remote function returning object type, the returned object always be primitive. Prototype would be JS primitive
Object
and all methods would be removed. I think such characteristic should be reflected to theDriver<Controller>
through the meta programming.Although a
Controller
has defined its functions to return non-primitive object,Driver
should convert the returned object type to be primitive. As you can see from the below example code, functions defined in theFeature
class return object type;Report
andMember
.However, when wrap the
Feature
class into theDriver
type, those functions are all converted to return the primitive object. The interfaceIReport
returned byDriver<Feature>
does not have any method. Remote functions returningMember
type are converted to returnIMember
type, which is derived from theMember.toJSON()
method.