2

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.

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.