当前位置: 动力学知识库 > 问答 > 编程问答 >

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;

}

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: