THRIFT-3508 Map optional fields from thrift idl to optional fields in TypeScript.
Client: node,js
Patch: Axel Jäger
This closes #2386
diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc
index fddcef4..48d7250 100644
--- a/compiler/cpp/src/thrift/generate/t_js_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc
@@ -909,13 +909,9 @@
out << indent() << dval << ";" << endl;
}
if (gen_ts_) {
- if (gen_node_) {
- f_types_ts_ << ts_indent() << "public " << (*m_iter)->get_name() << ": "
- << ts_get_type((*m_iter)->get_type()) << ";" << endl;
- } else {
- f_types_ts_ << ts_indent() << (*m_iter)->get_name() << ": "
- << ts_get_type((*m_iter)->get_type()) << ";" << endl;
- }
+ string ts_access = gen_node_ ? "public " : "";
+ f_types_ts_ << ts_indent() << ts_access << (*m_iter)->get_name() << ts_get_req(*m_iter) << ": "
+ << ts_get_type((*m_iter)->get_type()) << ";" << endl;
}
}