diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index 234c2be6..835ba441 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -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"; } diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/my-game/example/ability.ts index e2dadc97..02951cbf 100644 --- a/tests/ts/my-game/example/ability.ts +++ b/tests/ts/my-game/example/ability.ts @@ -33,7 +33,7 @@ mutate_distance(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "MyGame.Example.Ability" { return 'MyGame.Example.Ability'; } diff --git a/tests/ts/my-game/example/monster.ts b/tests/ts/my-game/example/monster.ts index 289f609a..bd64dd12 100644 --- a/tests/ts/my-game/example/monster.ts +++ b/tests/ts/my-game/example/monster.ts @@ -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'; } diff --git a/tests/ts/my-game/example/referrable.ts b/tests/ts/my-game/example/referrable.ts index 02d8cb1b..9affeedb 100644 --- a/tests/ts/my-game/example/referrable.ts +++ b/tests/ts/my-game/example/referrable.ts @@ -40,7 +40,7 @@ mutate_id(value:bigint):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "MyGame.Example.Referrable" { return 'MyGame.Example.Referrable'; } diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/my-game/example/stat.ts index 00b8845f..72cd032a 100644 --- a/tests/ts/my-game/example/stat.ts +++ b/tests/ts/my-game/example/stat.ts @@ -63,7 +63,7 @@ mutate_count(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "MyGame.Example.Stat" { return 'MyGame.Example.Stat'; } diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.ts b/tests/ts/my-game/example/struct-of-structs-of-structs.ts index 05bc63d5..af3519a0 100644 --- a/tests/ts/my-game/example/struct-of-structs-of-structs.ts +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.ts @@ -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'; } diff --git a/tests/ts/my-game/example/struct-of-structs.ts b/tests/ts/my-game/example/struct-of-structs.ts index e1fd746c..2f4a3674 100644 --- a/tests/ts/my-game/example/struct-of-structs.ts +++ b/tests/ts/my-game/example/struct-of-structs.ts @@ -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'; } diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.ts b/tests/ts/my-game/example/test-simple-table-with-enum.ts index ef6fa5d8..3e8b4c03 100644 --- a/tests/ts/my-game/example/test-simple-table-with-enum.ts +++ b/tests/ts/my-game/example/test-simple-table-with-enum.ts @@ -41,7 +41,7 @@ mutate_color(value:Color):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "MyGame.Example.TestSimpleTableWithEnum" { return 'MyGame.Example.TestSimpleTableWithEnum'; } diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/my-game/example/test.ts index db9263cf..40fff16e 100644 --- a/tests/ts/my-game/example/test.ts +++ b/tests/ts/my-game/example/test.ts @@ -33,7 +33,7 @@ mutate_b(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "MyGame.Example.Test" { return 'MyGame.Example.Test'; } diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/my-game/example/type-aliases.ts index 9f0ed0b2..2897e973 100644 --- a/tests/ts/my-game/example/type-aliases.ts +++ b/tests/ts/my-game/example/type-aliases.ts @@ -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'; } diff --git a/tests/ts/my-game/example/vec3.ts b/tests/ts/my-game/example/vec3.ts index 88c0dbf7..a2092d70 100644 --- a/tests/ts/my-game/example/vec3.ts +++ b/tests/ts/my-game/example/vec3.ts @@ -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'; } diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/my-game/example2/monster.ts index 39bf68d9..2016c84e 100644 --- a/tests/ts/my-game/example2/monster.ts +++ b/tests/ts/my-game/example2/monster.ts @@ -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'; } diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/my-game/in-parent-namespace.ts index 02f18e1a..1b67a08d 100644 --- a/tests/ts/my-game/in-parent-namespace.ts +++ b/tests/ts/my-game/in-parent-namespace.ts @@ -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'; } diff --git a/tests/ts/optional-scalars/scalar-stuff.ts b/tests/ts/optional-scalars/scalar-stuff.ts index e76088bc..7f6fdcaa 100644 --- a/tests/ts/optional-scalars/scalar-stuff.ts +++ b/tests/ts/optional-scalars/scalar-stuff.ts @@ -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'; } diff --git a/tests/ts/union_vector/attacker.ts b/tests/ts/union_vector/attacker.ts index 32675bcd..aecd4152 100644 --- a/tests/ts/union_vector/attacker.ts +++ b/tests/ts/union_vector/attacker.ts @@ -40,7 +40,7 @@ mutate_sword_attack_damage(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "Attacker" { return 'Attacker'; } diff --git a/tests/ts/union_vector/book-reader.ts b/tests/ts/union_vector/book-reader.ts index 2052fdcb..0fbb4c89 100644 --- a/tests/ts/union_vector/book-reader.ts +++ b/tests/ts/union_vector/book-reader.ts @@ -24,7 +24,7 @@ mutate_books_read(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "BookReader" { return 'BookReader'; } diff --git a/tests/ts/union_vector/falling-tub.ts b/tests/ts/union_vector/falling-tub.ts index 32fb9fa4..999a87ea 100644 --- a/tests/ts/union_vector/falling-tub.ts +++ b/tests/ts/union_vector/falling-tub.ts @@ -24,7 +24,7 @@ mutate_weight(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "FallingTub" { return 'FallingTub'; } diff --git a/tests/ts/union_vector/hand-fan.ts b/tests/ts/union_vector/hand-fan.ts index 03b809d3..ca0d2e70 100644 --- a/tests/ts/union_vector/hand-fan.ts +++ b/tests/ts/union_vector/hand-fan.ts @@ -40,7 +40,7 @@ mutate_length(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "HandFan" { return 'HandFan'; } diff --git a/tests/ts/union_vector/movie.ts b/tests/ts/union_vector/movie.ts index f3457fb4..2c6235e2 100644 --- a/tests/ts/union_vector/movie.ts +++ b/tests/ts/union_vector/movie.ts @@ -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'; } diff --git a/tests/ts/union_vector/rapunzel.ts b/tests/ts/union_vector/rapunzel.ts index 433106a6..8affb967 100644 --- a/tests/ts/union_vector/rapunzel.ts +++ b/tests/ts/union_vector/rapunzel.ts @@ -24,7 +24,7 @@ mutate_hair_length(value:number):boolean { return true; } -static getFullyQualifiedName():string { +static getFullyQualifiedName(): "Rapunzel" { return 'Rapunzel'; }