Skip to content

Symbol#getJsDocTags adds whitespace in URLs #42581

Closed

Description

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' }

Activity

  1. z0gSh1u commented on Feb 2, 2021

    @z0gSh1u
    Contributor

    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 typescript@4.1.3.

  2. sandersn commented on Apr 6, 2021

    @sandersn
    Member

    ZHUO Xu (@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.

  3. added
    Fix Available
    on Apr 23, 2021
  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugFix Available

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ Proxy