{"id":473,"date":"2017-01-23T21:51:09","date_gmt":"2017-01-23T21:51:09","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=473"},"modified":"2017-01-23T21:51:09","modified_gmt":"2017-01-23T21:51:09","slug":"allowing-typescript-to-understand-nativescripts-home-path","status":"publish","type":"post","link":"https:\/\/fluentreports.com\/blog\/?p=473","title":{"rendered":"Allowing TypeScript to understand NativeScripts ~\/ home path"},"content":{"rendered":"<p>I know a wide number of you use TypeScript; well one of the irritations I've had with TypeScript -- I just figured out how to solve.\u00a0\u00a0 Finally did some research and tests to figure out how to make TypeScript support using <strong>~\/ <\/strong>as a normal path for building and determining editor intellisense since this is a special path in NativeScript meaning the home app path. \u00a0 Using this path in a import \/ require statement means you can do something like this.<\/p>\n<p><strong>\/app\/views\/login\/login.ts<\/strong> -&gt; <em><pre><code>import * as animation from &#039;~\/support\/animation&#039;\n<\/code><\/pre><\/em>and it will load in the file at\u00a0\u00a0 <strong>\/app\/support\/animation<\/strong><\/p>\n<p>You can use relative paths, but I find absolute path's a lot easier to read and understand exactly which file is being loaded.\u00a0\u00a0 In addition things like my NativeScript-Updater can't use relative path's (do to some low level issues in the iOS runtimes) and determine if a file has been updated.<\/p>\n<p>Ok, so the solution: open your tsconfig.json file and add the following:<br \/>\n<pre>&quot;baseUrl&quot;: &quot;.&quot;,\n&quot;paths&quot;: {\n&nbsp;&nbsp; &quot;~\/*&quot;: [\n&nbsp;&nbsp;&nbsp;&nbsp; &quot;.\/*&quot;\n&nbsp;&nbsp; ]\n&nbsp;&nbsp;}<\/pre><br \/>\nTo the \"compilerOptions\" key in the json file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I know a wide number of you use TypeScript; well one of the irritations I've had with TypeScript -- I just figured out how to solve.\u00a0\u00a0 Finally did some research and tests to figure out how to make TypeScript support using ~\/ as a normal path for building and determining editor intellisense since this is&hellip; <a class=\"more-link\" href=\"https:\/\/fluentreports.com\/blog\/?p=473\">Continue reading <span class=\"screen-reader-text\">Allowing TypeScript to understand NativeScripts ~\/ home path<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[15,39,68],"tags":[97,16,96,69],"class_list":["post-473","post","type-post","status-publish","format-standard","hentry","category-nativescript","category-tips","category-typescript","tag-home","tag-nativescript","tag-path","tag-typescript","entry"],"_links":{"self":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=473"}],"version-history":[{"count":2,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":475,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/473\/revisions\/475"}],"wp:attachment":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}