{"id":4520,"date":"2016-06-18T02:15:14","date_gmt":"2016-06-18T02:15:14","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=4520"},"modified":"2016-06-18T02:15:14","modified_gmt":"2016-06-18T02:15:14","slug":"typescript-example-function-type","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/typescript-example-function-type\/","title":{"rendered":"TypeScript: example of a function type"},"content":{"rendered":"<p>TypeScript allows strongly typed functions\/lambda arguments.<\/p>\n<p>For instance, you might define a logging routine, where you delegate the actual log writing (console output, file output, etc) to a callback.<\/p>\n<p>To do this, you&#8217;d want to accept a function that takes a string, and returns nothing (unit, void, etc, depending on what you compare).<\/p>\n<p>You can do this easily:<\/p>\n<pre lang=\"typescript\">\nlet onLog: (value: string)=>void = \n  console.log;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>An example of function type arguments in TypeScript<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[302,557],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/4520"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=4520"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/4520\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=4520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=4520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=4520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}