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

[ID-Prep] Preserve all triple slash directives in declarations files #57439

Closed
6 tasks done
dragomirtitian opened this issue Feb 19, 2024 · 0 comments Β· Fixed by #57681
Closed
6 tasks done

[ID-Prep] Preserve all triple slash directives in declarations files #57439

dragomirtitian opened this issue Feb 19, 2024 · 0 comments Β· Fixed by #57681
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fix Available A PR has been opened for this issue Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@dragomirtitian
Copy link
Contributor

dragomirtitian commented Feb 19, 2024

The [ID-prep] set of issues aligns Declaration Emit with the forthcoming Isolated Declarations feature.

πŸ” Search Terms

preserve triple slash directives

βœ… Viability Checklist

⭐ Suggestion

Right now TypeScript will remove unused /// <reference types="..." /> directives.

πŸ“ƒ Motivating Example

// @declaration: true

// @filename: /a/node_modules/@types/node/index.d.ts
interface Error {
    stack2: string;
}

// @filename: /a/app.ts
/// <reference types="node"/>
// ^ is currently removed
function foo(): Error {
    return undefined;
}

Playground

πŸ’» Use Cases

  1. What do you want to use this for?

    Preserving all references would make it easier for other tools to create the same output as typescript for declaration files

  2. What shortcomings exist with current approaches?

    Other tools don't have enough type information to determine if the reference is used or not if they only look at one file.

  3. What workarounds are you using in the meantime?

    Currently other tools can't emit declaration files.

@dragomirtitian dragomirtitian changed the title Preserve all triple slash directives in declarations files [ID-Prep] Preserve all triple slash directives in declarations files Feb 19, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Feb 20, 2024
@RyanCavanaugh RyanCavanaugh added Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases labels Feb 20, 2024
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Suggestion An idea for TypeScript Breaking Change Would introduce errors in existing code and removed Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases labels Feb 21, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Fix Available A PR has been opened for this issue Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
4 participants