-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Treat link tag as comment #25206
Merged
+45
−1
Merged
Treat link tag as comment #25206
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly..json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"kind": "JSDocComment", | ||
"pos": 0, | ||
"end": 127, | ||
"tags": { | ||
"0": { | ||
"kind": "JSDocTag", | ||
"pos": 63, | ||
"end": 68, | ||
"atToken": { | ||
"kind": "AtToken", | ||
"pos": 63, | ||
"end": 64 | ||
}, | ||
"tagName": { | ||
"kind": "Identifier", | ||
"pos": 64, | ||
"end": 67, | ||
"escapedText": "see" | ||
}, | ||
"comment": "{@link second link text} and {@link Foo|a foo} as well." | ||
}, | ||
"length": 1, | ||
"pos": 63, | ||
"end": 68 | ||
}, | ||
"comment": "{@link first link}\nInside {@link link text} thing" | ||
} |
2 changes: 1 addition & 1 deletion
2
tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
Submodule TypeScript-Node-Starter
updated
49 files
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this handle
{@link}
(malformed tag) well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically a skip, so any sequence of
{@link
is handled correctly. It doesn't handle the unbraced@link ...
or the extra space in{ @link
, neither of which are legal jsdoc, but could occur.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about it a bit more:
@link
is formatted like a top-level tag, so I think it's fine to treat it as one.{
and@link
is a lot of work with the current tokeniser. We should switch to the normal tokeniser and then revisit this code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So only tags named "link" has this special behavior ? Isn't this kind of arbitrary and unexpected behavior? Reminds me something I heard about an old windows version having a code like
if(process.name==='the sims'){increaseSomething()}
.What's the reason for this? Is it for IDEs trying to support link in JavaScript projects ? Is it really important to hack the parser like this so one or two IDEs have an easy way of locating the parent tag description and position to insert a link ? They can still implement that (although it's harder/hacky/slow for them) without this hack in the compiler...
In which kind of projects are they trying to support @type ? Which reference syntax are these projects using , the usejsdocs.org one or TypeScript one?
In the later case, these projects are already breaking usejsdocs "standard" so they should not be using @link or {@link} but something else
In the first case, then I assume the motive for this hack is to support IDEs so they can easily/fast recreate the broken parent tag description and find the position to insert the anchor. If that's the case don't you think they should be responsible of solving their own problems? And if, as best case, they are just trying to solve the problem of jsdoc referencing once and for all, do you think this is the correct way of doing it?
If this is more or less right, then I'm worried that you didn't consider nor the compiler API user (for which BTW you introduced a breaking change), nor in the jsdoc writer for which TypeScript could provide typechecked references supporting refactors easily, and nor on typeScript developers since althoguh this change affected compiler performance minimally it shows performance place in this project priorities
I made an informal quick proposal #16498 (comment) and I would love to document in more detail discuss and implement it, but I would like first to know if such feature would be accepted ?
I think TypeScript now has the opportunity to define the definitely and single way of document JavaScript APIs as other languages have, and a feature like this would help a lot in that direction.
Don't take me wrong, I admire this project's contributors , but this just surprise me, sorry for the long comment, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was The Sims part of the Windows spec? In this case
@link
is part of jsdoc that Typescript explicitly wants to opt out of. And it's the only non-top-level tag in jsdoc, which means that code to support it (or skip it) will look special.