microsoft / microsoft/TypeScript-Website
Clarifying recommendation for when to publish types to DefinitelyTyped vs bundled
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 2.6k
- Fork
- 1.5k
- Merge medio
- 2g 2h
- PR unite (30g)
- 7
Descrizione
Per #2804, I am creating a new issue to replace #2032 with renewed clarity and purpose.
When publishing types, there are essentially two standard ways to do so:
Reading this, to me, "Otherwise" suggests that packages should only bundle their types if they were automatically generated.
This nicely covers two use cases:
- Source is in TypeScript. Published package is compiled to JavaScript alongside type definitions.
- Source is not in TypeScript. Package users independently publish and maintain types for the package.
I think a 3rd intermediate case is missing:
- Source is not in TypeScript. Code maintainer willing to add, maintain, and publish type definitions alongside source.
I've had passing conversations with maintainers that seemed to me to be under the impression that publishing manually created types separately was the preferred way to do it, seemingly because of this phrasing. Some even suggested doing this for TypeScript packages...
As far as I can tell, there is basically no downside to publishing accurate types along with source code, besides a marginal increase bundle size. The improved developer experience is well worth it and the types get compiled away for any real publishing. I would also think DefinitelyTyped would prefer if others did not rely on DT as it centralizes type issues in their respective packages and handles mismatched version issues intrinsically.
Suggestion for new phrasing
Including up-to-date types in published packages is always preferred. Bundling types improves developer experiences and reduces occurrence of common bugs and issues. If your types are generated by your source code, or you are keeping them up to date manually, we recommend you publish them with your published code bundle. Both TypeScript and JavaScript projects can generate types via declaration.
If you would prefer to not bundle your type definitions in your published package, we recommend submitting the types to DefinitelyTyped, which will publish them to the @types organization on npm.
If you do neither, any users of your package may still submit their own types to DefinitelyTyped.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da packages/documentation/copy/en/declaration-files/Publishing.md, in particolare dalle indicazioni nelle righe 11–16, e confronta la formulazione con il chiarimento proposto nell’issue. Il lavoro è completato quando la documentazione distingue chiaramente tra i tipi inclusi e le indicazioni di DefinitelyTyped per i progetti TypeScript e JavaScript.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100