Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty types in jsdoc #155

Open
michaelfranzl opened this issue Sep 27, 2023 · 4 comments
Open

Empty types in jsdoc #155

michaelfranzl opened this issue Sep 27, 2023 · 4 comments

Comments

@michaelfranzl
Copy link

michaelfranzl commented Sep 27, 2023

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:

" * @param {%s} %s $1",

@rensftw
Copy link

rensftw commented Nov 16, 2023

I can reproduce the same issue locally with Neogen at commit 70127ba

@sutt0n
Copy link

sutt0n commented Dec 14, 2023

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. 🤔

@mmgeorge
Copy link

Running into this as well

@AceCodePt
Copy link

Same with me :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants