File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -303,11 +303,21 @@ function saveMsgConstructorAsTSD(rosMsgInterface, fd) {
303303 const type = rosMsgInterface . type ( ) ;
304304 const msgName = type . interfaceName ;
305305
306+ fs . writeSync ( fd , ` export interface ${ msgName } Constants {\n` ) ;
307+ for ( const constant of rosMsgInterface . ROSMessageDef . constants ) {
308+ if ( primitiveType2JSName ( constant . type ) === "string" ) {
309+ fs . writeSync ( fd , ` ${ constant . name } = "${ constant . value } ";\n` ) ;
310+ } else {
311+ fs . writeSync ( fd , ` ${ constant . name } = ${ constant . value } ;\n` ) ;
312+ }
313+ }
314+ fs . writeSync ( fd , ' }\n' ) ;
315+
316+
306317 fs . writeSync ( fd , ` export interface ${ msgName } Constructor {\n` ) ;
307318
308319 for ( const constant of rosMsgInterface . ROSMessageDef . constants ) {
309- const constantType = primitiveType2JSName ( constant . type ) ;
310- fs . writeSync ( fd , ` readonly ${ constant . name } : ${ constantType } ;\n` ) ;
320+ s . writeSync ( fd , ` readonly ${ constant . name } : ${ msgName } Constants.${ constant . name } ;\n` ) ;
311321 }
312322
313323 fs . writeSync ( fd , ` new(other?: ${ msgName } ): ${ msgName } ;\n` ) ;
You can’t perform that action at this time.
0 commit comments