Skip to content

Symbol#getJsDocTags adds whitespace in URLs #42581

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

Closed
RomainMuller opened this issue Feb 1, 2021 · 2 comments · Fixed by #43800
Closed

Symbol#getJsDocTags adds whitespace in URLs #42581

RomainMuller opened this issue Feb 1, 2021 · 2 comments · Fixed by #43800
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@RomainMuller
Copy link

Bug Report

🔎 Search Terms

@see, JsDocTags

🕗 Version & Regression Information

This changed between 3.9 and 4.1.

💻 Code

/** @see http://lmgtfy.com */
export class Foo {}

🙁 Actual behavior

Consider the exported symbol Foo above... When calling getJsDocTags() on that, the result includes:

{ text: 'http ://lmgtfy.com', name: 'see' }
//           ^-- spurious space

🙂 Expected behavior

Expected the @see tag's text to be represented as-is:

{ text: 'http://lmgtfy.com', name: 'see' }
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Feb 1, 2021
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.3.0 milestone Feb 1, 2021
@z0gSh1u
Copy link
Contributor

z0gSh1u commented Feb 2, 2021

This specified problem is introduced since #39760. The parser of compiler always tries to parseJSDocNameReference although there might be none. So, for http://lmgtfy.com, it gets stuck at : since it's an UNKNOWN token for current grammar. Then, http becomes a NameReference, while ://lmgtfy.com is comment. However, the whole string is all comment in fact.

function parseSeeTag(start: number, tagName: Identifier, indent?: number, indentText?: string): JSDocSeeTag {

export function parseJSDocNameReference(): JSDocNameReference {

Same problem occurs with @implements and maybe more JSDoc annotations for [email protected].

@sandersn
Copy link
Member

sandersn commented Apr 6, 2021

@z0gSh1u's analysis is correct. The comment-parsing part of jsdoc parsing skips initial whitespace, which isn't correct for jsdoc where whitespace is usually significant. getJsDocTags then separates the name of a tag from the comment with a space. Unfortunately, it's a fairly large change to fix this.

The output of getJsDocTags is now DisplayParts in 4.3, but it still inserts the space.

sandersn added a commit that referenced this issue Apr 23, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Apr 23, 2021
sandersn added a commit that referenced this issue Apr 23, 2021
* Omit spaces after https in jsdoc comments

for tags with names.

Fxes #42581

* fix semicolon lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants