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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With