mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-12 07:50:59 +00:00
TS/JS: Export object based classes on entry (#7822)
* TS/JS: Export object based classes on entry
Along with the non object ones, for consistency. This is a regression
introduced recently.
Before:
`export { UpdateSettingsRequest } from './worker/update-settings-request.js';`
Now:
`export { UpdateSettingsRequest, UpdateSettingsRequestT } from './worker/update-settings-request.js';`
* only export object based classes for structs
Enums are not elegible.
---------
Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -255,7 +255,6 @@ class TsGenerator : public BaseGenerator {
|
||||
|
||||
for (const auto &it : ns_defs_) {
|
||||
code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n";
|
||||
|
||||
// export all definitions in ns entry point module
|
||||
int export_counter = 0;
|
||||
for (const auto &def : it.second.definitions) {
|
||||
@@ -281,7 +280,14 @@ class TsGenerator : public BaseGenerator {
|
||||
base_name_rel += base_file_name;
|
||||
auto ts_file_path_rel = base_name_rel + ".ts";
|
||||
auto type_name = def.first;
|
||||
code += "export { " + type_name + " } from '";
|
||||
auto fully_qualified_type_name =
|
||||
it.second.ns->GetFullyQualifiedName(type_name);
|
||||
auto is_struct = parser_.structs_.Lookup(fully_qualified_type_name);
|
||||
code += "export { " + type_name;
|
||||
if (parser_.opts.generate_object_based_api && is_struct) {
|
||||
code += ", " + type_name + parser_.opts.object_suffix;
|
||||
}
|
||||
code += " } from '";
|
||||
std::string import_extension =
|
||||
parser_.opts.ts_no_import_ext ? "" : ".js";
|
||||
code += base_name_rel + import_extension + "';\n";
|
||||
|
||||
Reference in New Issue
Block a user