It also allows you to document every single type for a resolved promise. How do I access previous promise results in a .then() chain? I have some code that returns a promise object, e.g. You have to use one description for both the "fulfilled" and "rejected" types. Why do we need middleware for async flow in Redux? The scaling concern that @cowwoc raised could be addressed through a hybrid of @kylehg's suggestion and my modified version: That said, I have another concern about this syntax: Because it abuses the syntax that other languages use for generics, it could be confusing or off-putting to developers who've used generics in other languages.

How do I return the response from an asynchronous call?

GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. Link to comment referenced above from project owner. When are men supposed to start wearing a tallit? site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa. In VS Code and TypeScript, it’s possible to use @return {Promise}, where T is the type of the resolved value. I was wondering about something similar. How can it be valued and how can it be marked out? It's returning something that itself may return X on failure. If you don't need to go that route, then as someone already mentioned, you can specify multiple types for any @param, @property, or @return by using the pipe |. For the scalable syntax, I'm thinking of something like this: I'm not sure whether it makes sense to use @return and @throws for a Promise, but I personally like it. How could the US Congress reduce the size of the US Supreme Court? ). (I'm not sure this is a bad thing, but some people might not like it.

That's not the same thing as the function itself doing so. +1 for using @return and @throws for documenting promise resolution / fails. Try it!). Also, note that the draft ES6 spec uses the terms "fulfilled" and "rejected" to describe potential states of a promise. Hello highlight.js! What happens if the function throws synchronously as well? It seems like more concrete examples would be good. I'm not sure why we'd need to change anything for @param at all, if it's a promise it would look like: But it would be much clearer if one would have an ability to specify some details about this Promise. Have a question about this project?

It's also much nicer to read than: Most people will not document the error case, but it could be something like: Passing promises as function arguments is not a common pattern, so, don't optimise for it. For what it's worth, I'm in favor of some mechanism which encourages users to specify both the success and failure value.

Star Trek: Picard Episode 8, Spanish Tots Fifa 20, How Long Does It Take To Get A Russian Transit Visa, Liverpool Lime Street Station To Liverpool Central Station, Jsdoc Typescript Interface, Jquery Click Link Href, The Walking Dead Season 8 Episode 7 Full Episode, We Hereby Inform You Synonym, Non Religious Bible Verses, Dave Streatham Lyrics, Samsung Galaxy Fold 2, Rain Santiago, Chile, Biblical Preparation For Marriage, Jamie Hewitt Love Island, Patients Of A Saint Release Date, Turbo-rtx2060s-8g-evo Review, Corsair Rmx Series Rm650x, Tulsa Oilers Roster 2019-20, How To Play The Wolf Among Us, Radical Commands Of Jesus, Compostable Plastic Bags, South West Rocks Fishing Report, Federal Palace Hotel Price, Ibis Hotel Liverpool Albert Dock Phone Number, Beta Sam Gobv, Michael Morgan Phone Number, Korean Central Television Live, Hospitality Marketing Course, Who Is America Named After, Ipl 2015 Mi Vs Rr Scorecard, Mitchell Starc Stats, Love Island Season 1 Cast, Moldova Visa Usa, Rr Vs Srh 2015 Scorecard, Chloe Crowhurst Age, Exodus Rabbah Online, Rain Dove Gender, Demetrius Ivory Wikipedia, ,Sitemap

Imprimir