@@ -42,7 +42,13 @@ function writeMessage(ctx, options) {
4242 if ( ! options . noRead ) {
4343 const readName = `read${ name } ` ;
4444 if ( options . jsDoc ) {
45- code += [ '\n/**' , ' * @param {Pbf} pbf' , ' * @param {number} [end]' , ` * @returns {${ name } }` , ' */' ] . join ( '\n' ) . concat ( '\n' ) ;
45+ code += `
46+ /**
47+ * @param {Pbf} pbf
48+ * @param {number} [end]
49+ * @returns {${ name } }
50+ */
51+ ` ;
4652 }
4753 code +=
4854`${ writeFunctionExport ( options , readName ) } function ${ readName } (pbf, end) {
@@ -55,7 +61,13 @@ function writeMessage(ctx, options) {
5561 const { key, value} = getMapTsType ( fields ) ;
5662 param = `{key: ${ key } ; value: ${ value } }` ;
5763 }
58- code += [ '\n/**' , ' * @param {number} tag' , ` * @param {${ param } } obj` , ' * @param {Pbf} pbf' , ' */' ] . join ( '\n' ) . concat ( '\n' ) ;
64+ code += `
65+ /**
66+ * @param {number} tag
67+ * @param {${ param } } obj
68+ * @param {Pbf} pbf
69+ */
70+ ` ;
5971 }
6072 code +=
6173`function ${ readName } Field(tag, obj, pbf) {
@@ -93,7 +105,12 @@ function writeMessage(ctx, options) {
93105 param = `{key: ${ key } ; value: ${ value } }` ;
94106 }
95107
96- code += [ '\n/**' , ` * @param {${ param } } obj` , ' * @param {Pbf} pbf' , ' */' ] . join ( '\n' ) . concat ( '\n' ) ;
108+ code += `
109+ /**
110+ * @param {${ param } } obj
111+ * @param {Pbf} pbf
112+ */
113+ ` ;
97114 }
98115
99116 code += `${ writeFunctionExport ( options , writeName ) } function ${ writeName } (obj, pbf) {\n` ;
@@ -480,12 +497,6 @@ function getMapTsType(fields) {
480497 return { key, value} ;
481498}
482499
483- /**
484- * @param {string } type
485- * @param {string } name
486- * @param {{name: string; type: string; required: boolean} } [fields]
487- * @returns {string }
488- */
489500function typeDef ( type , name , fields = [ ] ) {
490501 const unionProperties = { } ;
491502 const properties = fields . map ( ( field ) => {
@@ -512,16 +523,10 @@ function typeDef(type, name, fields = []) {
512523 . concat ( '\n' ) ;
513524}
514525
515- /**
516- * @param {object } ctx
517- * @param {string } name
518- * @param {{name: string; type: string; required: boolean} } [fields]
519- * @returns {string }
520- */
521526function compileType ( ctx , name , fields = [ ] ) {
522527 if ( ctx . _proto . map ) {
523528 const { key, value} = getMapTsType ( fields ) ;
524- return typeDef ( `Object <${ key } , ${ value } >` , name , [ ] ) ;
529+ return typeDef ( `Record <${ key } , ${ value } >` , name , [ ] ) ;
525530 }
526531
527532 const typedFields = fields . map ( ( field ) => {
0 commit comments