So far, Error, Object and non-flat Enum have all grown instanceOf methods.
This ticket is to generate instanceOf methods for all types:
add a instanceOf(obj: any): obj is T to FfiConverter.
for types with existing instanceOf methods, the converter should call that type's static methods.
for object, the FfiConverter takes a factory which is generated. This should have the instanceOf method.
for primitive types, these can be hard coded e.g. typeof v === 'number'.
for Record, an structural types, we can implement the FfiConverter.instanceOf in terms of other FfiConverter.instanceOf methods, recursively calling instanceOf until a false is found.
Add instanceOf to the decl_type_name objects: mostly, I think for Record, but there may be others.
So far,
Error
,Object
and non-flatEnum
have all growninstanceOf
methods.This ticket is to generate instanceOf methods for all types:
instanceOf(obj: any): obj is T
toFfiConverter
.instanceOf
methods, the converter should call that type's static methods.FfiConverter
takes afactory
which is generated. This should have theinstanceOf
method.typeof v === 'number'
.Record
, an structural types, we can implement theFfiConverter.instanceOf
in terms of otherFfiConverter.instanceOf
methods, recursively calling instanceOf until afalse
is found.instanceOf
to thedecl_type_name
objects: mostly, I think forRecord
, but there may be others.Consider a record:
then, in the
FfiConverterTypeMyRecord
aninstanceOf
method can be implemented: