Repository navigation
fix: keep brackets at the start of a nameless tag description - #274
Open
TheeCoderAhmed wants to merge 1 commit into
Open
TheeCoderAhmed wants to merge 1 commit into
TheeCoderAhmed wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #269
What breaks
A nameless tag whose description starts with
[gets rewritten, and its type gets widened:becomes
Why
comment-parserreads a leading[x, y]as an optional name, so the tag comes back withname: "x, y"andoptional: true.normalizeTagsfolds that name back into the description for tags inTAGS_NAMELESS, but it keepsoptionalanddefaultand uses the name without its brackets.assignOptionalAndDefaultToNamethen seesoptionalwith an empty name and appends| undefined.What changed
When the name is folded into the description,
normalizeTagsnow uses the raw[...]text from the source tokens and clearsoptionalanddefault. This goes a little past the fix suggested in the issue, because clearing the state alone would still printX, ywithout the brackets, and the issue expects the input to stay unchanged.normalizeTagsruns before the{string=}conversion, so@returns {string=} textstill becomesstring | undefined.@param {string} [x=1]is not a nameless tag, so it is not affected.What I ran
yarn install --frozen-lockfile --ignore-scriptswith yarn 1.22.22 on Node 22.23.tsc --project tsconfig.json, thenjestwith thets-node/esmloader: 16 suites, 148 tests, 204 snapshots pass. The new test intests/main.test.tsfailed before the change with@returns {number[] | undefined} X, y.eslint --ext .ts ./src, andprettier --checkon the two changed files.@default,@defaultValue,@example,@description,@deprecated,@throws,@returns {string=}and@paraminputs through the built plugin, to check the output by eye. It is not part of this PR.I did not run the CI matrix of other Node and Prettier versions, and I did not run
yarn testitself, since it also runs the build script.