Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing android package in nativescript using typescript

I get the following error message:

main-page.ts(15,26): error TS2304: Cannot find name 'android'.

After creating a new nativescript project using typescript.

tns create demo --template typescript

And adding the following xml, ts files.

main-page.xml

<Page xmlns="http://schemas.nativescript.org/tns.xsd">
  <StackLayout>
    <Placeholder creatingView="creatingView"/>
  </StackLayout>
</Page>

main-page.ts

import placeholder = require("ui/placeholder");

export function creatingView(args: placeholder.CreateViewEventData) {
    var nativeView = new android.widget.CalendarView(args.context);
    args.view = nativeView;
}
like image 579
Luiz Honda Avatar asked Dec 10 '22 16:12

Luiz Honda


1 Answers

That's a TypeScript compiler warning, it's not an error per se. You can install the platform definitions into your Nativescript project if you want to prevent these warnings: npm i tns-platform-declarations

You could still run the TSC to transpile the TypeScript into Javascript and it work. It's just for type checking warning which is the benefit of TypeScript :)

Hope all of this makes sense and helps out.

https://www.npmjs.com/package/tns-platform-declarations

like image 159
Brad Martin Avatar answered Dec 28 '22 08:12

Brad Martin