microsoft / microsoft/TypeScript
JSDoc optional property in object
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
TypeScript Version: 3.9.x & 4.1.x
Search Terms: jsdoc optional
There seems to be a regression since version 3.9.x where optional params in JSDocs are not converted correctly in declaration files. Several issues were created (linked below) and patches were made, however, it seems that params nested inside objects are still not correctly handled as optional when surrounded by brackets.
Code
/**
* Does Foo
*
* @param {object} opts
* @param {string} [opts.bar] - is optional
* @returns void
*/
function foo(opts ) {
// ..
}
Expected behavior: (as well as actual behavior <=3.8.3)
declare function foo(opts: {
bar?: string;
}): void;
Actual behavior:
declare function foo(opts: {
bar: string;
}): void;
Related Issues:
https://github.com/microsoft/TypeScript/issues/39111 was addressed with https://github.com/microsoft/TypeScript/pull/39487, but it doesn't seem that nested properties were covered in that fix.
https://github.com/microsoft/TypeScript/pull/39123 and https://github.com/microsoft/TypeScript/pull/39457 seem to relate to Closure notation, not sure if they're related.
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 riproducendo l’esempio JSDoc fornito con TypeScript 3.9.x e 4.1.x, confrontando la dichiarazione generata con la proprietà annidata facoltativa prevista. Poi leggi issue #39111 e pull request #39487 per comprendere la correzione correlata; il lavoro è completato quando le proprietà annidate tra parentesi quadre vengono emesse con ? nella dichiarazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100