Skip to content

Commit 4290ef4

Browse files
author
Teo Koon Peng
authored
fix possible error when generating typescript definitions (#600)
small change to fix error when generating ros-gazebo messages. ros-gazebo includes services that end with Request like BodyRequest and LinkRequest. This causes the check to determine if an idl is a service to fail as it only checks if it ends with Request.
1 parent a5edb33 commit 4290ef4

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

rostsd_gen/index.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ function getPkgInfos(generatedRoot) {
6666

6767
if (typeClass.type === 'srv') {
6868
// skip __srv__<action>
69-
if (
70-
!typeClass.name.endsWith('Request') &&
71-
!typeClass.name.endsWith('Response')
72-
) {
69+
if (!typeClass.name.endsWith('_Request') && !typeClass.name.endsWith('_Response')) {
7370
pkgInfo.services.push(typeClass);
7471
continue;
7572
}
@@ -198,10 +195,7 @@ function savePkgInfoAsTSD(pkgInfos, fd) {
198195
fs.writeSync(fd, ';\n\n');
199196
}
200197

201-
fs.writeSync(
202-
fd,
203-
' type TypeClassName = MessageTypeClassName | ServiceTypeClassName;\n'
204-
);
198+
fs.writeSync(fd, ' type TypeClassName = MessageTypeClassName | ServiceTypeClassName;\n');
205199

206200
// close module declare
207201
fs.writeSync(fd, '}\n');
@@ -232,13 +226,7 @@ function saveMsgWrapperAsTSD(msgInfo, fd) {
232226
* non-primitive types
233227
* @returns {undefined}
234228
*/
235-
function saveMsgFieldsAsTSD(
236-
msgInfo,
237-
fd,
238-
indent = 0,
239-
lineEnd = ',',
240-
typePrefix = ''
241-
) {
229+
function saveMsgFieldsAsTSD(msgInfo, fd, indent = 0, lineEnd = ',', typePrefix = '') {
242230
const indentStr = ' '.repeat(indent);
243231
for (let i = 0; i < msgInfo.def.fields.length; i++) {
244232
const field = msgInfo.def.fields[i];

0 commit comments

Comments
 (0)