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

TypeScript emits incorrect type for setters in JSDoc #58167

Closed
remcohaszing opened this issue Apr 12, 2024 · 0 comments Β· Fixed by #58172
Closed

TypeScript emits incorrect type for setters in JSDoc #58167

remcohaszing opened this issue Apr 12, 2024 · 0 comments Β· Fixed by #58172

Comments

@remcohaszing
Copy link

πŸ”Ž Search Terms

jsdoc set

πŸ•— Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.5&filetype=js#code/KYDwDg9gTgLgBAYwDYEMDOa4DUBiBLJYOAbwCg44B6AKmvIurgAEpgYBXKAO02LRih4uAcwC+9ONUr1hbOGBQwAFgAoAlCQlxWHbnADk++uPo06FScwVQUAWxIBVAEoAZOAB84-QSNHzFShJS9GhyCsoq4UoaZBTiJggQPPAAZgREALxwXMAA7tj4hOqkaYQAdFFwWfqUaBC2wJRRRqXAFQFV2Xlwzi4q+q0AXJQjdQ1NAfpqQA

πŸ’» Code

export class VFile {
  /**
   * @returns {string}
   */
  get path() {
    return ''
  }

  /**
   * @param {URL | string} path
   */
  set path(path) {
  }
}

const file = new VFile()
file.path = '/some/path'
file.path = new URL('file:///some/path')

πŸ™ Actual behavior

  • βœ”οΈ The setter type annotation is used for type checking the setter
  • ❌ The getter type annotation is emitted as the setter type in the .d.ts file

πŸ™‚ Expected behavior

The setter type annotation should be emitted as the setter type

Additional information about the issue

This only affects types in JSDoc. Correct types are emitted for the equivalent TypeScript code.

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

Successfully merging a pull request may close this issue.

1 participant