Skip to content

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

Closed

Description

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.

Activity

  1. changed the title [-]Preserve all triple slash directives in declarations files[/-] on Feb 19, 2024
  2. added
    Possible Improvement
    on Feb 20, 2024
  3. added
    Bug
    Suggestion
    Breaking Change
    and removed
    Possible Improvement
    on Feb 21, 2024
  4. added
    Fix Available
    on Mar 20, 2024
  5. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeBugFix AvailableSuggestion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions