{"id":308,"date":"2016-05-22T01:59:52","date_gmt":"2016-05-22T01:59:52","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=308"},"modified":"2016-05-22T02:25:42","modified_gmt":"2016-05-22T02:25:42","slug":"nativescript-typescript-and-accessing-native-android-runtimes","status":"publish","type":"post","link":"https:\/\/fluentreports.com\/blog\/?p=308","title":{"rendered":"NativeScript, TypeScript and accessing native Android runtimes"},"content":{"rendered":"<p>When you are trying to access any of the native android platform using TypeScript, TS will complain about the root name --<br \/>\n<code>TS2304: Cannot find name &#039;zzzz&#039; at line yyyy<\/code><\/p>\n<p>TypeScript is unaware that those variables exist and are actually global in scope; so to make TypeScript happy; in your code you will want to do something like this:<\/p>\n<p><pre><code>declare var android: any;\ndeclare var com: any;\ndeclare var java: any;<\/code><\/pre><\/p>\n<p>This will tell TypeScript that these are global, so it will no longer throw an error when you try to access any classes that start with android, java, or com. If you are accessing any other classes that Android publishes, you can also use the same technique: <strong>declare var <em>zzzz<\/em>: any;<\/strong><\/p>\n<p>Small update; Josh mentioned it via twitter about installing the tns-platform-declarations.\u00a0 I'm not sure why I didn't post this here also -- so I'm updating the post a tad -- installing the tns-platform-declarations will get you intellisense for the android &amp; ios platforms.\u00a0 It is well worth the download if you are using native ios or android calls.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you are trying to access any of the native android platform using TypeScript, TS will complain about the root name -- TS2304: Cannot find name &#039;zzzz&#039; at line yyyy TypeScript is unaware that those variables exist and are actually global in scope; so to make TypeScript happy; in your code you will want to&hellip; <a class=\"more-link\" href=\"https:\/\/fluentreports.com\/blog\/?p=308\">Continue reading <span class=\"screen-reader-text\">NativeScript, TypeScript and accessing native Android runtimes<\/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":[17,16,70,69],"class_list":["post-308","post","type-post","status-publish","format-standard","hentry","category-nativescript","category-tips","category-typescript","tag-android","tag-nativescript","tag-ts2304","tag-typescript","entry"],"_links":{"self":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/308","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=308"}],"version-history":[{"count":4,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":312,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions\/312"}],"wp:attachment":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}