{"id":1618,"date":"2023-10-12T05:00:00","date_gmt":"2023-10-12T12:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=1618"},"modified":"2023-10-02T15:29:41","modified_gmt":"2023-10-02T22:29:41","slug":"typescript-cheatsheet-control-flow","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/typescript-cheatsheet-control-flow\/","title":{"rendered":"Typescript Cheatsheet: Control Flow"},"content":{"rendered":"\n<p>A few weeks back, I shared a cheat sheet for <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/typescript-cheatsheet-classes\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Typescript classes<\/a>. Today, I want to share a cheat sheet on control flow, which will change in <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/new-control-flow-rfc\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Angular templates very soon<\/a>.<\/p>\n\n\n\n<p>Note the different type narrowing options, such as: if (&#8220;property&#8221; in object), which can come in handy instead of creating extra types. Type guards are exciting as well, though rarely used in Angular applications:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/www.typescriptlang.org\/static\/TypeScript%20Control%20Flow%20Analysis-8a549253ad8470850b77c4c5c351d457.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"724\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/TypeScript-Control-Flow-Analysis-8a549253ad8470850b77c4c5c351d457-1024x724.png\" alt=\"\" class=\"wp-image-1621\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/TypeScript-Control-Flow-Analysis-8a549253ad8470850b77c4c5c351d457-1024x724.png 1024w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/TypeScript-Control-Flow-Analysis-8a549253ad8470850b77c4c5c351d457-300x212.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/TypeScript-Control-Flow-Analysis-8a549253ad8470850b77c4c5c351d457-768x543.png 768w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/TypeScript-Control-Flow-Analysis-8a549253ad8470850b77c4c5c351d457.png 1330w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Click this link to\u00a0<a href=\"https:\/\/www.typescriptlang.org\/static\/TypeScript%20Control%20Flow%20Analysis-8a549253ad8470850b77c4c5c351d457.png\" target=\"_blank\" rel=\"noopener\" title=\"\">see a larger version in a browser<\/a>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few weeks back, I shared a cheat sheet for Typescript classes. Today, I want to share a cheat sheet on control flow, which will change in Angular templates very soon. Note the different type narrowing options, such as: if (&#8220;property&#8221; in object), which can come in handy instead of creating extra types. Type guards [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1618","post","type-post","status-publish","format-standard","hentry","category-typescript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=1618"}],"version-history":[{"count":1,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1618\/revisions"}],"predecessor-version":[{"id":1622,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1618\/revisions\/1622"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=1618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=1618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=1618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}