This TypeScript programming tutorial goes into detail on how optional chaining can be utilized to streamline conditionals in an application. Practical ways that optional chaining can be used:
- Ensuring that data render attempts are only attempted after an application receives data from an API
- Allows for cleaner, more maintainable code since the conditionals can be built directly into the program instead of having to build ‘guard’ based conditionals.
- Preventing errors from occurring when a server sends unexpected data
Source code:
https://gist.github.com/jordanhudgens/594f96cfd50475331eedde28e2be3edb