neogen
neogen copied to clipboard
Empty types in jsdoc
I would like to have jsdoc in a typescript file (I don't want to use tsdoc, because tsdoc does not annotate types). This use case does not work, even though it was mentioned as implemented in issue #15.
To reproduce, use an up-to-date neogen
, nvim-treesitter
and nvim
, with all other plugins disabled.
For the file test.ts
:
function func(a: number, b:string): string {
return b + a;
}
with the following :InspectTree
:
(function_declaration) ; [1:1 - 3:1]
name: (identifier) ; [1:10 - 13]
parameters: (formal_parameters) ; [1:14 - 34]
(required_parameter) ; [1:15 - 23]
pattern: (identifier) ; [1:15 - 15]
type: (type_annotation) ; [1:16 - 23]
(predefined_type) ; [1:18 - 23]
(required_parameter) ; [1:26 - 33]
pattern: (identifier) ; [1:26 - 26]
type: (type_annotation) ; [1:27 - 33]
(predefined_type) ; [1:28 - 33]
return_type: (type_annotation) ; [1:35 - 42]
(predefined_type) ; [1:37 - 42]
body: (statement_block) ; [1:44 - 3:1]
(return_statement) ; [2:2 - 14]
(binary_expression) ; [2:9 - 13]
left: (identifier) ; [2:9 - 9]
right: (identifier) ; [2:13 - 13]
with the following configuration:
require('neogen').setup {
languages = {
typescript = {
template = {
annotation_convention = "jsdoc",
},
},
},
}
Running :Neogen func
adds:
/**
* @param {} a
* @param {} b
* @returns {}
*/
However I expected:
/**
* @param {number} a
* @param {string} b
* @returns {string}
*/
This is the relevant code:
https://github.com/danymat/neogen/blob/70127baaff25611deaf1a29d801fc054ad9d2dc1/lua/neogen/templates/jsdoc.lua#L16
I can reproduce the same issue locally with Neogen at commit 70127ba
This also happens on my end. Although, I will add that it seems Object-based types work, more primitive types (number, boolean, string) do not.
Edit: It seems to be a variation in type_identifier
versus predefined_type
. 🤔
Running into this as well
Same with me :(