Skip to content
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

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

Closed
MichaelMitchell-at opened this issue Feb 21, 2025 · 0 comments · Fixed by #61261
Closed
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@MichaelMitchell-at
Copy link
Contributor

MichaelMitchell-at commented Feb 21, 2025

🔎 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants