{"id":7053,"date":"2019-05-12T20:19:31","date_gmt":"2019-05-12T20:19:31","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=7053"},"modified":"2019-05-12T20:19:31","modified_gmt":"2019-05-12T20:19:31","slug":"using-lodash-in-typescript","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/using-lodash-in-typescript\/","title":{"rendered":"Using lodash in TypeScript"},"content":{"rendered":"<p>Was trying to use <em>lodash<\/em> and couldn&#8217;t seem to get Visual Code to build my TypeScript files correctly, so here&#8217;s how to get it working&#8230;<\/p>\n<p>Add the following <em>esModuleInterop<\/em> to your tsconfig.json <\/p>\n<pre class=\"brush: java; highlight: [5]; title: ; notranslate\" title=\"\">\r\n{\r\n    &quot;compilerOptions&quot;: {\r\n        &quot;target&quot;: &quot;es5&quot;,\r\n        &quot;module&quot;: &quot;commonjs&quot;,\r\n        &quot;esModuleInterop&quot;: true,\r\n        &quot;sourceMap&quot;: true\r\n    }\r\n}\r\n<\/pre>\n<p>and then you can use<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport _ from &quot;lodash&quot;;\r\n<\/pre>\n<p>Otherwise you can use the following if <em>esModuleInterop<\/em> doesn&#8217;t exist or is set to false<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport * as _ from &quot;lodash&quot;;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Was trying to use lodash and couldn&#8217;t seem to get Visual Code to build my TypeScript files correctly, so here&#8217;s how to get it working&#8230; Add the following esModuleInterop to your tsconfig.json { &quot;compilerOptions&quot;: { &quot;target&quot;: &quot;es5&quot;, &quot;module&quot;: &quot;commonjs&quot;, &quot;esModuleInterop&quot;: true, &quot;sourceMap&quot;: true } } and then you can use import _ from &quot;lodash&quot;; Otherwise [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[46],"tags":[],"class_list":["post-7053","post","type-post","status-publish","format-standard","hentry","category-typescript"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=7053"}],"version-history":[{"count":3,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7053\/revisions"}],"predecessor-version":[{"id":7056,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7053\/revisions\/7056"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=7053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=7053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=7053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}