Include resolve type in API documentation for Promise return types
See original GitHub issueThe API documentation for functions that use promises list Promise
as the return type for the function (e.g. documentation for DS.Store.findAll). While technically correct, this is nearly useless from a documentation perspective, since it doesn’t tell you what type the promise resolves to.
This becomes more noticeable when using the async/await syntax, where the promise gets hidden behind the scenes. For example:
let records = await store.findAll('users');
There’s nothing in the documentation to indicate what the type of records
is.
To improve the usability of the documentation, I propose including the type of the resolved value of the Promise in the @return
tag so it appears in the generated API docs.
One syntax would be to use the same syntax as generics, so to indicate that the promise resolves to a DS.Model object, the JSDocs would be:
/**
* @return {Promise<DS.Model>} a promise which returns a single instance of the model`
*/
Which would then allow the API docs to show Promise<DS.Model>
as the return type.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:11 (10 by maintainers)
@fastfedora if you have any questions about Ember Data, @skaterdav85 wrote a great book on the subject 😃
Fixed in #15316. Thank you!