hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
232 stars 28 forks source link

`@overload` is incorrectly positioned #192

Closed sxxov closed 1 year ago

sxxov commented 1 year ago

The @overload tag should always preceed @returns, otherwise TypeScript will complain that no return type is defined for that specific overload.

Example

Expected Behaviour

/**
* Get user from session
*
* @overload
* @returns {Promise<ResultStrict<ApiOk<User>>>}
*/ /**
* Get user from id
*
* @overload
* @param {string} userId
* @returns {Promise<ResultStrict<ApiAny<ForeignUser | User>>>}
*/ /**
* @param {string | undefined} userId
* @returns {Promise<ResultStrict<ApiAny<ForeignUser | User>>>}
*/
async getUser(userId = undefined) {
// ...

Actual Behaviour

/**
* Get user from session
*
* @returns {Promise<ResultStrict<ApiOk<User>>>}
* @overload
*/ /**
* Get user from id
*
* @param {string} userId
* @returns {Promise<ResultStrict<ApiAny<ForeignUser | User>>>}
* @overload
*/ /**
* @param {string | undefined} userId
* @returns {Promise<ResultStrict<ApiAny<ForeignUser | User>>>}
*/
async getUser(userId = undefined) {
// ...

Error

image