Skip to content

Renamed field takes on documentation from other field with the same nameΒ #55434

@ilyvion

Description

@ilyvion

πŸ”Ž Search Terms

"renamed field docs"
"renamed field documentation"

πŸ•— Version & Regression Information

  • This changed between versions 4.5 and 4.6

⏯ Playground Link

https://www.typescriptlang.org/play?#code/C4TwDgpgBAYg9nKBeKBvAUFLUD0AqPTbKPKAFQAsBLAOwHMoqBnKAQygCNWAnI7PHH0ZMAQjwBcnBABsIrGkPyFiJctXrC2nVgC8hJQcWZidkjjLkKAvunQAzAK40AxsCpwaUOhGDw4ACgBKST80IW4fB25PJwATCDtaCFi2FnkQdBt0Zw8mYDRhE0ljHigrZC8fPyCAbmzcuFkAOniOBzp-Eu5AmqA

πŸ’» Code

type Foo = {
    /**
     * Thing is a bar
     */
    isBar: boolean
    /**
     * Thing is a baz
     */
    isBaz: boolean
}

function getFoo(): Foo {
    return undefined as any
}

const { isBaz: isBar } = getFoo();
console.debug(isBar);

πŸ™ Actual behavior

If you inspect the tooltip/documentation for the isBar that is the renamed isBaz from the call to getFoo(), it takes on the docs for the actual isBar rather than isBaz (or nothing) (screenshot is from the playground with 5.1.6):
image

While that would be the correct documentation if it were in fact, the actual isBar, this one is actually isBaz and should have isBaz's docs.

πŸ™‚ Expected behavior

Despite me renaming isBaz to another field that also exists, it should either still show the docs for isBaz for the renamed variable, or at least nothing.

Additional information about the issue

I say this changed between 4.5 and 4.6, but that's mainly because in 4.5 and earlier versions, the renamed version shows no documentation at all. 4.6 and later still show no documentation if you rename the field to something not present in the original type (screenshot is from the playground with 5.1.6):
image

Personally, I'd prefer it if the renamed version still showed the docs from the original, but nothing is still better than wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions