microsoft / microsoft/TypeScript
Generating declaration file (.d.ts) for a single module
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Suggestion
🔍 Search Terms
So many I can't list them all here, everything related to declaration files, .d.ts generation, .d.ts rollup, import ellision, etc.
✅ Viability Checklist
My suggestion meets these guidelines:
- 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 feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
Add an option to generate a .d.ts file for a single module.
📃 Motivating Example
I currently have a repository which exposes a set of types I need to use in another repo (and for legacy reasons a monorepo isn't possible). The thing is, generating a declaration file for the project will generate declaration for all modules inside this project.
What I want is only the declaration of a specific module in that project.
Let's say for instance the project contains index.ts, router.ts and schema.ts. Generating a declaration file will emit declarations for everything exported by these three files. But what I want is only what is exported by schema.ts, as it will be used for validation in another repository, whereas the other two files contain business logic that have nothing to do elsewhere, and also depend on packages that won't be available in the other repo.
💻 Use Cases
- Exporting specific types to another repository
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the declaration-generation behavior for the mentioned index.ts, router.ts, and schema.ts modules, comparing whole-project output with the requested single-module case. The issue does not name compiler files or tests, so those would need to be located first. Done means an option can emit declarations for only schema.ts without requiring declarations for the other modules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100