{"id":3933,"date":"2016-04-30T01:18:31","date_gmt":"2016-04-30T01:18:31","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3933"},"modified":"2016-04-30T01:18:31","modified_gmt":"2016-04-30T01:18:31","slug":"typescript-import-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/typescript-import-example\/","title":{"rendered":"TypeScript import example"},"content":{"rendered":"<p>In Typescript &#8220;imports&#8221; are called &#8220;references&#8221;.<\/p>\n<p>If you have a type definition file (.d.ts) you can import it directly with a comment:<\/p>\n<pre lang=\"javascript\">\n\/\/\/ <reference path=\"..\/typings\/jquery.d.ts\"\/>\n<\/pre>\n<p>I think most people at the moment are moving to a tool called &#8220;typings&#8221;, which helps you find an manage local copes of these files for your libraries. <\/p>\n<p>The type definition files feel a little kludgey, but they really are equivalent to .h (header) files in C, basically you&#8217;re defining that something exists, but the actual call will be handled post-compilation: at runtime, in the case of Javascript, rather than using a linker, in C.<\/p>\n<p>Because of this property, Typescript tends to try to generate Javascript code if it can, even if it thinks you&#8217;re doing something that is a bad idea. I&#8217;ve so far found a lot of minor defects because of it&#8217;s enforcement, although pretty much any error has been a warning.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How importing external libraries and files work 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":[12],"tags":[302,557],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3933"}],"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=3933"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3933\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}