mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 22:20:56 +00:00
[JS] Add getFullyQualifiedName() (#6119)
This optionally generates a static `getFullyQualifiedName()` function to get the fully-qualified name of a type in JavaScript and TypeScript in a similar fashion to the C++ codegen.
This commit is contained in:
@@ -1783,6 +1783,18 @@ class JsTsGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
// Emit the fully qualified name
|
||||
if (parser_.opts.generate_name_strings) {
|
||||
GenDocComment(code_ptr, GenTypeAnnotation(kReturns, "string", "", false));
|
||||
if (lang_.language == IDLOptions::kTs) {
|
||||
code += "static getFullyQualifiedName():string {\n";
|
||||
} else {
|
||||
code += object_name + ".getFullyQualifiedName = function() {\n";
|
||||
}
|
||||
code += " return '" + WrapInNameSpace(struct_def) + "';\n";
|
||||
code += "}\n\n";
|
||||
}
|
||||
|
||||
// Emit a factory constructor
|
||||
if (struct_def.fixed) {
|
||||
std::string annotations =
|
||||
|
||||
Reference in New Issue
Block a user