Skip to content

fix(valid-types): fix parsing of expressions like @returns {@link SomeType} #1382

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 1 commit into from
May 14, 2025

Conversation

LukeAbby
Copy link
Contributor

@LukeAbby LukeAbby commented May 10, 2025

Fixed #1381.

I looked at a handful of ways to do this:

  • Hook into @es-joy/jsdoccoment's parseComment function. Specifically I was hoping to wrap the type parsing logic. This seemed like the most elegant option but it fell flat. While this is technically possible I would have to hardcode that getTransformer returns the type parser at index 1 in order to wrap it and make it aware of this edge case.
  • Rerun the parser with noTypes set to include the tag. While possible it'd mean rerunning parsing from scratch. I'm okay with switching to this approach if you'd like.
  • What I actually did, which is to move tag.type to tag.description if it looks like a JSDoc tag. The type parser expects the type to be formatted as exactly {type} and whitespace is preserved so the conversion back is currently lossless. However even if the parser were to change to parse out more forms (e.g. {type}), I reason that it doesn't really matter because description isn't even checked in the rest of valid-types.

@LukeAbby LukeAbby force-pushed the main branch 2 times, most recently from a6e2879 to d7c6930 Compare May 10, 2025 06:59
@LukeAbby LukeAbby changed the title Allow expressions like @returns {@link SomeType} fix(valid-types): fix parsing of expressions like @returns {@link SomeType} May 10, 2025
@LukeAbby LukeAbby changed the title fix(valid-types): fix parsing of expressions like @returns {@link SomeType} fix(valid-types): fix parsing of expressions like @returns {@link SomeType} May 10, 2025
@LukeAbby LukeAbby closed this May 10, 2025
@LukeAbby
Copy link
Contributor Author

The pre-commit hooks seems to be somewhat buggy. Specifically I ran git rebase upstream main on one of my branches and it ended up switching the branch to main. This happened even when successful and I would expect it to switch back. I would also expect it to work in a temporary worktree or something as to avoid changing the branch pointer mid complicated commands that might not behave well.

All in all this caused a number of commands to be run on the wrong branch which needless to say was confusing. In particular it caused this PR to be closed because I ended up accidentally resetting main to upstream/main and since there were then no commits the PR was auto-closed by GitHub (even though it says I closed it)

@LukeAbby LukeAbby reopened this May 10, 2025
Repository owner deleted a comment May 10, 2025
@LukeAbby
Copy link
Contributor Author

LukeAbby commented May 13, 2025

@brettz9 I understand this is sort of an incomplete workaround. If you would prefer not to merge as is, I can look into adopting TypeDoc.

@brettz9
Copy link
Collaborator

brettz9 commented May 13, 2025

Just need a little time to review...

@LukeAbby
Copy link
Contributor Author

Sorry! Totally my bad. The flurry of activity elsewhere got me second guessing myself. Happy to wait otherwise, as long as it's on your list.

@brettz9
Copy link
Collaborator

brettz9 commented May 13, 2025

No worries--all good... Yup, on the list...

@brettz9 brettz9 added the bug label May 14, 2025
@brettz9 brettz9 merged commit 2bd7242 into gajus:main May 14, 2025
5 checks passed
Copy link

🎉 This issue has been resolved in version 50.6.16 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

valid-types cannot parse links right after another tag
2 participants