Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TS codegen - change getFullyQualifiedName return type from string to string literal #8421

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/idl_gen_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,11 +1941,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";
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mutate_distance(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "MyGame.Example.Ability" {
return 'MyGame.Example.Ability';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/monster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/referrable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mutate_id(value:bigint):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "MyGame.Example.Referrable" {
return 'MyGame.Example.Referrable';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/stat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mutate_count(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "MyGame.Example.Stat" {
return 'MyGame.Example.Stat';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/struct-of-structs-of-structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/struct-of-structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/test-simple-table-with-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mutate_color(value:Color):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "MyGame.Example.TestSimpleTableWithEnum" {
return 'MyGame.Example.TestSimpleTableWithEnum';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mutate_b(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "MyGame.Example.Test" {
return 'MyGame.Example.Test';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/type-aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example/vec3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/example2/monster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/my-game/in-parent-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/optional-scalars/scalar-stuff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/union_vector/attacker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mutate_sword_attack_damage(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "Attacker" {
return 'Attacker';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/union_vector/book-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mutate_books_read(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "BookReader" {
return 'BookReader';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/union_vector/falling-tub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mutate_weight(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "FallingTub" {
return 'FallingTub';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/union_vector/hand-fan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mutate_length(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "HandFan" {
return 'HandFan';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/union_vector/movie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ts/union_vector/rapunzel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mutate_hair_length(value:number):boolean {
return true;
}

static getFullyQualifiedName():string {
static getFullyQualifiedName(): "Rapunzel" {
return 'Rapunzel';
}

Expand Down
Loading