[TS] Enum value default null (#8619)

* [TS] Enum value default null

* Re-gen
This commit is contained in:
Björn Harrtell
2025-06-22 07:25:56 +02:00
committed by GitHub
parent 5822c1c8dd
commit 595ac94a6a
7 changed files with 9 additions and 9 deletions

View File

@@ -1849,7 +1849,7 @@ class TsGenerator : public BaseGenerator {
code += "BigInt(0)";
} else if (IsScalar(field.value.type.element)) {
if (field.value.type.enum_def) {
code += field.value.constant;
code += "null";
} else {
code += "0";
}

View File

@@ -457,7 +457,7 @@ export class Monster {
}
vectorOfEnums(index) {
const offset = this.bb.__offset(this.bb_pos, 98);
return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : null;
}
vectorOfEnumsLength() {
const offset = this.bb.__offset(this.bb_pos, 98);

View File

@@ -594,7 +594,7 @@ anyAmbiguous<T extends flatbuffers.Table>(obj:any):any|null {
vectorOfEnums(index: number):Color|null {
const offset = this.bb!.__offset(this.bb_pos, 98);
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : null;
}
vectorOfEnumsLength():number {

View File

@@ -29,7 +29,7 @@ export class D {
}
testVectorOfUnionType(index) {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0;
return offset ? this.bb.readInt32(this.bb.__vector(this.bb_pos + offset) + index * 4) : null;
}
testVectorOfUnionTypeLength() {
const offset = this.bb.__offset(this.bb_pos, 8);

View File

@@ -40,7 +40,7 @@ testUnion<T extends flatbuffers.Table>(obj:any):any|null {
testVectorOfUnionType(index: number):ABC|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0;
return offset ? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : null;
}
testVectorOfUnionTypeLength():number {

View File

@@ -32,7 +32,7 @@ export class Movie {
}
charactersType(index) {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : null;
}
charactersTypeLength() {
const offset = this.bb.__offset(this.bb_pos, 8);

View File

@@ -44,7 +44,7 @@ mainCharacter<T extends flatbuffers.Table>(obj:any|string):any|string|null {
charactersType(index: number):Character|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : null;
}
charactersTypeLength():number {