Reputation: 71
I have the following code in my typescript file
const startActivity: android.app.Activity = app.android.startActivity;
const context: android.content.Context = app.android.context;
let intent: android.content.Intent;
why does it shows an error 'cannot find namespace 'android'. Do i need to install plugin related to native android (eg tns-platform-declarations)
Thanks.
Your help is very much appreciated.
Upvotes: 2
Views: 2211
Reputation: 6147
Yep, you're correct. Use the tns-platform-declarations
and follow the setup it provides so that TypeScript is aware of the native android/ios APIs.
After installing, the main thing is to create a references.d.ts
file in the root of your project with the following:
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
Also be sure to pay attention to this from the docs:
d.ts files require a lot of memory and CPU. Consider adding skipLibCheck option to tsconfig file.
Upvotes: 6