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

when appending "default description" to description, imported types are repeated #229

Open
boneskull opened this issue Mar 12, 2024 · 0 comments

Comments

@boneskull
Copy link

boneskull commented Mar 12, 2024

Given:

/**
 * A thing that does stuff
 * @template {any[]} [T=import('foo').Something]
 * @param {T} values Stuff.
 */
function doStuff (values) {
}

Invoking prettier will result in this:

/**
 * A thing that does stuff
 * @template {any[]} [T=import('foo').Something] Default is `import('foo').Something`
 * @param {T} values Stuff. 
 */
function doStuff (values) {
}

But if we invoke prettier again, we get this:

/**
 * A thing that does stuff
 * @template {any[]} [T=import('foo').Something] Default is `import('foo').Something` Default is `import('foo').Something`
 * @param {T} values Stuff. 
 */
function doStuff (values) {
}

And again:

/**
 * A thing that does stuff
 * @template {any[]} [T=import('foo').Something] Default is `import('foo').Something` Default is `import('foo').Something` Default is `import('foo').Something`
 * @param {T} values Stuff. 
 */
function doStuff (values) {
}

(linebreaks will be added to the description of values as well)

This does not happen if we do, e.g.,:

/**
 * @typedef {import('foo').Something} Something
 */

/**
 * A thing that does stuff
 * @template {any[]} [T=Something]
 * @param {T} values Stuff.
 */
function doStuff (values) {
}

This results in:

/**
 * A thing that does stuff
 * @template {any[]} [T=Something]  Default is `Something`
 * @param {T} values Stuff.
 */
function doStuff (values) {
}

Subsequent prettier invocations will not cause Default is Something to be repeated.

This may be difficult to reproduce and I'm still trying to isolate it. It may only apply to docstrings for a class (not a function), or if @implements is present.

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

1 participant