Skip to content

Commit

Permalink
adding fb import when no other imports are present
Browse files Browse the repository at this point in the history
  • Loading branch information
krojew committed Jul 17, 2020
1 parent 969d0f7 commit 598203b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ grpc/google/
**/Package.resolved
.clangd/**
package-lock.json
/*.ilk
/*.pdb
6 changes: 5 additions & 1 deletion src/idl_gen_js_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,15 @@ class JsTsGenerator : public BaseGenerator {
// Emit namespaces in a form that Closure Compiler can optimize
std::string &code = *code_ptr;
std::string &exports = *exports_ptr;

if (lang_.language == IDLOptions::kTs) {
code += "import * as flatbuffers from 'flatbuffers';\n";
}

for (auto it = sorted_namespaces.begin(); it != sorted_namespaces.end();
++it) {
if (lang_.language == IDLOptions::kTs) {
if (it->find('.') == std::string::npos) {
code += "import * as flatbuffers from 'flatbuffers';\n";
break;
}
} else {
Expand Down

0 comments on commit 598203b

Please sign in to comment.