Skip to content

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

Closed
@MichaelMitchell-at

Description

@MichaelMitchell-at

πŸ”Ž 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.ts
import { object } from "./obj";

export const _ = object;

///////////
/**
 * huh
 */
// @filename: obj.d.ts
export declare const object: import("./id").Id<{
    foo: import("./id" ).Id<{}>;
}>;

// @filename: id.d.ts
export type Id<T> = T;

πŸ™ Actual behavior

a.d.ts is emitted as

export declare const _: {
    foo: import(
    /**
     * huh
     */ "./id" /**
     * huh
     */).Id<{}>;
};
/**
 * huh
 */

πŸ™‚ Expected behavior

a.d.ts emitted as

export declare const _: {
    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
@Andarist @dragomirtitian @jakebailey @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