microsoft / microsoft/TypeScript

Generating declaration file (.d.ts) for a single module

Offen
#54,408 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem Verhalten der Deklarationsgenerierung für die genannten Module index.ts, router.ts und schema.ts und vergleiche die Ausgabe für das gesamte Projekt mit dem angeforderten Fall eines einzelnen Moduls. Im Issue werden keine Compiler-Dateien oder Tests genannt, daher müssten diese zunächst gefunden werden. Erledigt ist die Aufgabe, wenn eine Option Deklarationen nur für schema.ts erzeugen kann, ohne Deklarationen für die anderen Module zu benötigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.