Skip to content

Reused nodes leak comment ranges for other files, leading to bad declaration emit #61239

Description

🔎 Search Terms

declaration syntax invalid comment docstring reuse

🕗 Version & Regression Information

This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?target=7&composite=true&ts=5.8.1-rc#code/PTAEAEGMHsFsAdoGcCWAXApgLlGgTgK4YBQIES+KkaO+RpY4AJhpADYCGeHaK0AdrUIky4JAAtoAdwCisdA3KTZ8tJiYAxFG2ygOAOib60SYovAAzbRn4dYugyeIoE0PGlABvUNABGAK1YPAF9QCzw4UAAifWA-fyiAbjMMAA9Ed1AYfgpQAH1QAF4fAKDkhhBKqtIAKhriUBrQcQJxBprgcysdW3sceMNjUzSMjxZ2LgwsgVz4oJwXUYAKGOAUJiiASn0ASSYAHk8G0BOLaGgF13cV2PWo0G29w+CAPmTX8tFumztddcGnCM3B40ABPeBTJ4AFReRVAUPKQA

💻 Code

// @composite: true// @strict: true// @declaration: true// @showEmit// @showEmittedFile: a.d.ts// @filename: a.tsimport{object}from"./obj";exportconst_=object;////////////** * huh */// @filename: obj.d.tsexportdeclareconstobject: import("./id").Id<{foo: import("./id").Id<{}>;}>;// @filename: id.d.tsexporttypeId<T>=T;

🙁 Actual behavior

a.d.ts is emitted as

exportdeclareconst_: {foo: import(/** * huh */"./id"/** * huh */).Id<{}>;};/** * huh */

🙂 Expected behavior

a.d.ts emitted as

exportdeclareconst_: {foo: import("./id").Id<{}>;};/** * huh */

Additional information about the issue

This seems to be a continuation of #58807, which #58810 did not fully resolve. cc
Mateusz Burzyński (@Andarist)Titian Cernicova-Dragomir (@dragomirtitian)Jake Bailey (@jakebailey)Wesley Wigham (@weswigham)

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