4 ms·
It would be interesting if this documentation was written directly into the code itself. For instance the default value is already right there. TypeScript adds
by clarkdale 4y ago
It would be interesting if this documentation was written directly into the code itself. For instance the default value is already right there. TypeScript adds the type information. If there was a way to add comments on each parameter name, so that the compiler didn't remove it, that would be neat. I mean inside the function itself.
- augusto-moura 4y agoFlow Type had a way of embedding type code in JS block comments [1]. There is an open issue for Typescript, but it looks it didn't went too far [2] [1]: https://flow.org/en/docs/types/comments/ https://flow.org/en/docs/types/comments/ [2]: https://github.com/microsoft/TypeScript/issues/9694 https://github.com/microsoft/TypeScript/issues/9694
- orta 4y agoHere's hoping https://tc39.es/proposal-type-annotations/ https://tc39.es/proposal-type-annotations/ solves this
- eyelidlessness 4y agoFor what it’s worth, there’s also TSDoc[1] which is TypeScript’s sorta-equivalent spiritual successor, and notably uses the same format as JSDoc. Inline type annotation is great—and I vastly prefer it to JSDoc as a type annotation mechanism—but supporting the breadth of documentation capability in an inline code position would probably be unwieldy no matter how you try to accommodate it. 1: https://tsdoc.org/ https://tsdoc.org/