From 81724e5b2030a6f9f4d38893a4aeb4ad5e1f7fc8 Mon Sep 17 00:00:00 2001 From: Max Burke Date: Fri, 6 Jan 2023 16:42:26 -0800 Subject: [PATCH] Ensure that empty modules can build in TypeScript isolatedModules mode (#7726) --- src/idl_gen_ts.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index ce3404bde..ca95e4a38 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -277,6 +277,13 @@ class TsGenerator : public BaseGenerator { for (auto it = imports_all_.begin(); it != imports_all_.end(); it++) { code += it->second.export_statement + "\n"; } + + if (imports_all_.empty()) { + // if the file is empty, add an empty export so that tsc doesn't + // complain when running under `--isolatedModules` mode + code += "export {}"; + } + const std::string path = GeneratedFileName(path_, file_name_, parser_.opts); SaveFile(path.c_str(), code, false);