microsoft / microsoft/TypeScript
Add support for `@file` jsdoc tag to describe a module
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
🔍 Search Terms
fileoverview
✅ 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
JSDoc supports the @file tag to document a file (module). Synonyms are @fileoverview and @overview.
Currently TypeScript allows you to document a module like this:
/**
* This comment describes `some-module`.
*/
declare module 'some-module' {
/**
* This comment describes `fn`.
*/
export function fn(): unknown;
}
This description shows up when you hover over an import of some-module.
However, it’s generally considered more idiomatic avoid declare module:
/**
* This comment describes `fn`.
*/
export function fn(): unknown;
In this case, there’s not way to describe the module.
I believe the @file tag provides a perfect way to describe a module. So the following code would be equivalent to the original example above.
/**
* @file
* This comment describes `some-module`.
*/
/**
* This comment describes `fn`.
*/
export function fn(): unknown;
I noticed that current module descriptions show up on hover, but not in autocomplete. I believe it would be nice to add support for that too.
📃 Motivating Example
TypeScript now supports the @file tag to describe a module.
💻 Use Cases
- What do you want to use this for?
I would describe modules. It would be nice to generate documentation from source as well.
- What shortcomings exist with current approaches?
It can’t be done without declare module.
- What workarounds are you using in the meantime?
I don’t document modules.
Guida per i contributori
Apri la guida per i contributori
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 tracciando come vengono raccolte e mostrate in hover le descrizioni dei moduli esistenti, quindi esamina l’elaborazione di JSDoc e i percorsi di autocomplete. Determina come i tag @file, @fileoverview e @overview debbano identificare un modulo senza declare module. Il lavoro è completo quando le descrizioni dei moduli funzionano per il pattern di esportazione mostrato e compaiono in modo coerente in hover e autocomplete.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- developer-experience, documentation
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100