flatbuffers
flatbuffers copied to clipboard
[TS] Weakened typing for unions in version 2
It seems that with flatc 2.0.0, the generated calls for unions have weakened type. Taking the monster tutorial as example, a struct having a member equipped
of type Equipment
will now generate the following method:
equipped<T extends flatbuffers.Table>(obj:any):any|null { ... }
while before 2.0, the following method would be generated:
equipped<T extends flatbuffers.Table>(obj:T):T|null { ... }
This is a problem, because before the type system would ensure that if the right object is passed in, the right object gets out. Now we do not even have this assurance, forcing to decorate this call with as InputType
like in:
const equipment = monster.equipped(new Equipment()) as Equipment | null;
Is there a reason for this weakening? The template parameter is still in the generated code, but it is not used any more...
@bjornharrtell
Agreed likely unintended regression.
This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.
Commenting to avoid stale issue deletion. I think we want this addressed.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale
, or this will be closed in 14 days.
Commenting to avoid stale issue deletion.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale
, or this will be closed in 14 days.
Commenting to avoid stale issue deletion.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale
, or this will be closed in 14 days.
Commenting to avoid stale issue deletion.