-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
The [ID-prep] set of issues aligns Declaration Emit with the forthcoming Isolated Declarations feature.
π Search Terms
preserve triple slash directives
β Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β 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;
}
π» Use Cases
-
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
-
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.
-
What workarounds are you using in the meantime?
Currently other tools can't emit declaration files.
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript