mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 23:12:02 +00:00
adding fb import when no other imports are present (#6030)
Co-authored-by: Kamil Rojewski <kamil.rojewski@gmail.com> Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -127,4 +127,6 @@ grpc/google/
|
|||||||
**/Package.resolved
|
**/Package.resolved
|
||||||
.clangd/**
|
.clangd/**
|
||||||
package-lock.json
|
package-lock.json
|
||||||
.clwb
|
/*.ilk
|
||||||
|
/*.pdb
|
||||||
|
.clwb
|
||||||
|
|||||||
@@ -214,11 +214,15 @@ class JsTsGenerator : public BaseGenerator {
|
|||||||
// Emit namespaces in a form that Closure Compiler can optimize
|
// Emit namespaces in a form that Closure Compiler can optimize
|
||||||
std::string &code = *code_ptr;
|
std::string &code = *code_ptr;
|
||||||
std::string &exports = *exports_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();
|
for (auto it = sorted_namespaces.begin(); it != sorted_namespaces.end();
|
||||||
++it) {
|
++it) {
|
||||||
if (lang_.language == IDLOptions::kTs) {
|
if (lang_.language == IDLOptions::kTs) {
|
||||||
if (it->find('.') == std::string::npos) {
|
if (it->find('.') == std::string::npos) {
|
||||||
code += "import * as flatbuffers from 'flatbuffers';\n";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// automatically generated by the FlatBuffers compiler, do not modify
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
import * as flatbuffers from 'flatbuffers';
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user