Skip to content

support @type on parameters #1427

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

Merged
merged 2 commits into from
Jul 21, 2025
Merged

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Jul 21, 2025

I noticed this in Svelte, where it's used on arrows with no obvious place to put a @param tag.

longFunction(x, y, (/** @type {number} */ n) => n + 1))

sandersn added 2 commits July 21, 2025 06:26
I noticed this in Svelte, where it's used on arrows with no obvious
place to put a `@param` tag.
@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 13:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the @type JSDoc tag on function parameters, allowing type annotations to be applied directly to parameters as an alternative to @param tags. This feature is particularly useful for arrow functions where @param tags may not have an obvious placement location.

  • Extends the reparser to handle @type tags on parameter declarations
  • Updates type inference to recognize and apply @type annotations to parameters
  • Improves type accuracy for React component parameters using @type annotations

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

File Description
internal/parser/reparser.go Adds handling for @type tags on parameter declarations in the reparser
testdata/baselines/reference/submodule/conformance/jsDeclarationsReactComponents.* Test baseline updates showing improved type inference for React component parameters
testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsReactComponents.types.diff Baseline diff reduction showing convergence with TypeScript behavior

@sandersn sandersn added this pull request to the merge queue Jul 21, 2025
Merged via the queue into microsoft:main with commit d222dd8 Jul 21, 2025
22 checks passed
@sandersn sandersn deleted the type-tag-on-params branch July 21, 2025 16:55
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 this pull request may close these issues.

2 participants