mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 22:03:40 +00:00
Ensure optional arrays, arrays with defaults, and strings with defaults are supported (#8896)
Fixing issues with generated ts/js
This commit is contained in:
23
tests/even_more_defaults.fbs
Normal file
23
tests/even_more_defaults.fbs
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
enum ABC: int { A, B, C }
|
||||
|
||||
struct EvenMoreStruct {
|
||||
g:[int64:2];
|
||||
}
|
||||
|
||||
table EvenMoreDefaults {
|
||||
str: EvenMoreStruct;
|
||||
ints: [int] = [];
|
||||
floats: [float] = [ ];
|
||||
float_optional: [float];
|
||||
bytes_optional: [ubyte];
|
||||
floats_required: [float] (required);
|
||||
empty_string: string = "";
|
||||
some_string: string = "some";
|
||||
zero_string: string = "0";
|
||||
a_string:string (key);
|
||||
required_string: string (required);
|
||||
abcs: [ABC] = [];
|
||||
bools: [bool] = [];
|
||||
one_bool: bool = true;
|
||||
}
|
||||
@@ -87,6 +87,20 @@ flatc(
|
||||
)
|
||||
esbuild("monster_test.ts", "monster_test_generated.cjs")
|
||||
|
||||
flatc(
|
||||
options=[
|
||||
"--ts",
|
||||
"--reflect-names",
|
||||
"--gen-name-strings",
|
||||
"--gen-mutable",
|
||||
"--gen-object-api",
|
||||
"--ts-entry-points",
|
||||
"--ts-flat-files",
|
||||
],
|
||||
schema="../even_more_defaults.fbs",
|
||||
include="../include_test",
|
||||
)
|
||||
|
||||
flatc(
|
||||
options=["--gen-object-api", "-b"],
|
||||
schema="../monster_test.fbs",
|
||||
|
||||
@@ -81,11 +81,11 @@ mutate_hp(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
name():string|null
|
||||
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
|
||||
name(optionalEncoding?:any):string|Uint8Array|null {
|
||||
name():string
|
||||
name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array
|
||||
name(optionalEncoding?:any):string|Uint8Array {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 10);
|
||||
return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
|
||||
return this.bb!.__string(this.bb_pos + offset, optionalEncoding);
|
||||
}
|
||||
|
||||
inventory(index: number):number|null {
|
||||
|
||||
Reference in New Issue
Block a user