forked from BigfootDev/flatbuffers
Update ts codegen (#8421)
Makes the return type of `static getFullyQualifiedName()` be a string literal instead of just the string type Update tests Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
This commit is contained in:
@@ -1944,11 +1944,15 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
// Emit the fully qualified name
|
||||
if (parser_.opts.generate_name_strings) {
|
||||
const std::string fullyQualifiedName = struct_def.defined_namespace->GetFullyQualifiedName(struct_def.name);
|
||||
|
||||
GenDocComment(code_ptr);
|
||||
code += "static getFullyQualifiedName():string {\n";
|
||||
code += "static getFullyQualifiedName(): \"";
|
||||
code += fullyQualifiedName;
|
||||
code += "\" {\n";
|
||||
code +=
|
||||
" return '" +
|
||||
struct_def.defined_namespace->GetFullyQualifiedName(struct_def.name) +
|
||||
fullyQualifiedName +
|
||||
"';\n";
|
||||
code += "}\n\n";
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ mutate_distance(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.Ability" {
|
||||
return 'MyGame.Example.Ability';
|
||||
}
|
||||
|
||||
|
||||
@@ -813,7 +813,7 @@ mutate_double_inf_default(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.Monster" {
|
||||
return 'MyGame.Example.Monster';
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ mutate_id(value:bigint):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.Referrable" {
|
||||
return 'MyGame.Example.Referrable';
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ mutate_count(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.Stat" {
|
||||
return 'MyGame.Example.Stat';
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ a(obj?:StructOfStructs):StructOfStructs|null {
|
||||
return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb!);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.StructOfStructsOfStructs" {
|
||||
return 'MyGame.Example.StructOfStructsOfStructs';
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ c(obj?:Ability):Ability|null {
|
||||
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.StructOfStructs" {
|
||||
return 'MyGame.Example.StructOfStructs';
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ mutate_color(value:Color):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.TestSimpleTableWithEnum" {
|
||||
return 'MyGame.Example.TestSimpleTableWithEnum';
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ mutate_b(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.Test" {
|
||||
return 'MyGame.Example.Test';
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ vf64Array():Float64Array|null {
|
||||
return offset ? new Float64Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.TypeAliases" {
|
||||
return 'MyGame.Example.TypeAliases';
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ test3(obj?:Test):Test|null {
|
||||
return (obj || new Test()).__init(this.bb_pos + 26, this.bb!);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example.Vec3" {
|
||||
return 'MyGame.Example.Vec3';
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ static getSizePrefixedRootAsMonster(bb:flatbuffers.ByteBuffer, obj?:Monster):Mon
|
||||
return (obj || new Monster()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.Example2.Monster" {
|
||||
return 'MyGame.Example2.Monster';
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ static getSizePrefixedRootAsInParentNamespace(bb:flatbuffers.ByteBuffer, obj?:In
|
||||
return (obj || new InParentNamespace()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "MyGame.InParentNamespace" {
|
||||
return 'MyGame.InParentNamespace';
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ defaultEnum():OptionalByte {
|
||||
return offset ? this.bb!.readInt8(this.bb_pos + offset) : OptionalByte.One;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "optional_scalars.ScalarStuff" {
|
||||
return 'optional_scalars.ScalarStuff';
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ mutate_sword_attack_damage(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "Attacker" {
|
||||
return 'Attacker';
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ mutate_books_read(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "BookReader" {
|
||||
return 'BookReader';
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ mutate_weight(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "FallingTub" {
|
||||
return 'FallingTub';
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ mutate_length(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "HandFan" {
|
||||
return 'HandFan';
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ charactersLength():number {
|
||||
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "Movie" {
|
||||
return 'Movie';
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ mutate_hair_length(value:number):boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName():string {
|
||||
static getFullyQualifiedName(): "Rapunzel" {
|
||||
return 'Rapunzel';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user