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

JSDoc types not supported #27590

Closed
johndeighan opened this issue Jan 8, 2025 · 2 comments
Closed

JSDoc types not supported #27590

johndeighan opened this issue Jan 8, 2025 · 2 comments
Labels
needs info needs further information to be properly triaged

Comments

@johndeighan
Copy link

$ deno --version
deno 2.1.4 (stable, release, x86_64-pc-windows-msvc)
v8 13.0.245.12-rusty
typescript 5.6.2

JSDoc allows you to specify the type of parameters or the return value in JavaScript code like:

/**
 * Represents a book.
 * @param {string} title - The title of the book.
 * @param {string} author - The author of the book.
 * @returns {boolean}
 */
function Book(title, author) {
}

However, though Deno 2 claims to support both TypeScript and JavaScript development, it doesn't support this method of specifying types. To be more specific, when I include JSDoc like the above, the {string} and {boolean} strings are ignored and the documentation produced doesn't include the type of parameters or return values.

@dsherret
Copy link
Member

dsherret commented Jan 8, 2025

Can you show a full reproduction (What does your file look like? What command are you running?)? Does that javascript file have // @ts-check at the top?

@dsherret dsherret added the needs info needs further information to be properly triaged label Jan 8, 2025
@johndeighan
Copy link
Author

Since the input file is a JavaScript file, it definitely does not have // @ts-check anywhere in it. Here is a sample input file, which I've named book.js and placed in my src/lib folder:

/**
 * book - provides functions for use in unit tests
 *
 * @module
 */

/**
 * Represents a book
 *
 * @param {string} title
 * @param {string} author
 * @returns {boolean}
 */

export const book = (title, author) => {

	return true
}

Note that this is JSDoc's standard way of specifying types for parameters (see https://jsdoc.app/tags-param).

Next, I run deno doc --html src/lib/book.js (my project has the folder src/lib). This command creates a folder named docs, which contains a bunch of files, including an index.html. When I open that file with Chrome, I see this:

image

When I click on the word book, I see this:

image

Note that there is no type information associated with the parameters, and the return type is listed as "unknown", even though the type information is there in my JSDoc block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info needs further information to be properly triaged
Projects
None yet
Development

No branches or pull requests

2 participants