-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
I came across a missing boolean/number conversion issue when compiling files with generated mutable APIs (--gen-mutable flag).
Given the following schema:
struct s {
flag: bool;
}
table t {
flag: bool;
}
Compiled with flatc (version 25.2.10):
> flatc --ts --gen-mutable -o ./tmp tmp.fbsThe mutable API for struct s will have the following:
mutate_flag(value:boolean):boolean {
this.bb!.writeInt8(this.bb_pos + 0, value);
return true;
}Which causes an error with TypeScript 5.9.2:
error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
21 this.bb!.writeInt8(this.bb_pos + 0, value);
~~~~~
Equivalent generated API for table t does have the correct boolean-to-number conversion (using preceding +):
mutate_flag(value:boolean):boolean {
const offset = this.bb!.__offset(this.bb_pos, 4);
if (offset === 0) {
return false;
}
this.bb!.writeInt8(this.bb_pos + offset, +value);
return true;
}Metadata
Metadata
Assignees
Labels
No labels