microsoft / microsoft/TypeScript
JSDoc optional property in object
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das bereitgestellte JSDoc-Beispiel mit TypeScript 3.9.x und 4.1.x zu reproduzieren, und vergleiche die erzeugte Deklaration mit der erwarteten optionalen verschachtelten Eigenschaft. Lies anschließend issue #39111 und pull request #39487, um den zugehörigen Fix zu verstehen; abgeschlossen ist die Aufgabe, wenn verschachtelte Eigenschaften in eckigen Klammern in der Deklaration mit ? ausgegeben werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100