Encountering an issue with the nativescript-carousel due to tns-platform-declarations

While constructing a nativescript carousel using the nativescript-carousel plug-in, I encountered an issue when running tns build android. The error message reads as follows:

node_modules/nativescript-carousel/index.d.ts(1,22): error TS6053: File 'D:/Documents/coursera_examples/nativescript/VilcabambaHotel/node_modules/nativescript-carousel/node_modules/tns-platform-declarations/android.d.ts' not found.

Below is the code snippet for my carousel in home.component.html:

    <GridLayout  horizontalAlignment="center" verticalAlignment="top" rows="*" columns="*" height="95%">        
    <Carousel #carousel ios:indicatorOffset="0,-10" ios:finite="true" ios:bounce="false" showIndicator="true" height="100%" indicatorAnimation="SWAP"
        indicatorColor="#66ccff" indicatorColorUnselected="#cceeff" height="250" width="80%">
        <CarouselItem backgroundColor="white" height="100%">
            <GridLayout *ngIf="cabin">
                <Image  [src]="BaseURL + cabin.image" ></Image>
            </GridLayout>
        </CarouselItem>
        <CarouselItem backgroundColor="white">
           <GridLayout *ngIf="house">
                <Image  [src]="BaseURL + house.image" ></Image>
            </GridLayout>
        </CarouselItem>
        <CarouselItem backgroundColor="white">
           <GridLayout *ngIf="ecoactivity">
                <Image  [src]="BaseURL + ecoactivity.image" ></Image>
            </GridLayout>
        </CarouselItem>
    </Carousel>
    </GridLayout>

This is how my home.component.ts looks like:

import { Component, OnInit, Inject, ChangeDetectorRef } from '@angular/core';

//import { TNSFontIconService } from 'nativescript-ngx-fonticon';
import { Page } from "ui/page";
import { View } from "ui/core/view";
import { SwipeGestureEventData, SwipeDirection } from "ui/gestures";
import * as enums from "ui/enums";

import { Cabin } from '../shared/cabin';
import { CabinService } from '../services/cabin.service';
import { House } from '../shared/house';
import { HouseService } from '../services/house.service';
import { Ecoactivity } from '../shared/ecoactivity';
import { EcoactivityService } from '../services/ecoactivity.service';
import { DrawerPage } from '../shared/drawer/drawer.page';



import { registerElement } from 'nativescript-angular/element-registry';
import { Carousel, CarouselItem } from 'nativescript-carousel';

registerElement('Carousel', () => Carousel);
registerElement('CarouselItem', () => CarouselItem);

@Component({
    selector: 'app-home',
    moduleId: module.id,
    templateUrl: './home.component.html',
    // styleUrls: ['./home.component.css']
})
export class HomeComponent extends DrawerPage implements OnInit {

    cabin: Cabin;
    house: House;
    ecoactivity: Ecoactivity;
    cabinErrMess: string;
    houseErrMess: string;
    ecoactivityErrMess: string;


    constructor(private cabinservice: CabinService,
        private houseservice: HouseService,
        private ecoactivityservice: EcoactivityService,
        private changeDetectorRef: ChangeDetectorRef,
        private page: Page,
       // private fonticon: TNSFontIconService,
        @Inject('BaseURL') private BaseURL) {
        super(changeDetectorRef);
    }

    ngOnInit() {
        this.cabinservice.getFeaturedCabin()
            .subscribe(cabin => this.cabin = cabin,
                errmess => this.cabinErrMess = <any>errmess);
        this.houseservice.getFeaturedHouse()
            .subscribe(house => this.house = house,
                errmess => this.houseErrMess = <any>errmess);
        this.ecoactivityservice.getFeaturedEcoactivity()
            .subscribe(ecoactivity => this.ecoactivity = ecoactivity,
                errmess => this.ecoactivityErrMess = <any>errmess);

    }

The error disappears if I remove the following lines of code, but it causes the carousel to stop functioning:

import { registerElement } from 'nativescript-angular/element-registry'; import { Carousel, CarouselItem } from 'nativescript-carousel';

To address this issue, I created a file named reference.d.ts with the below content, yet the error persists:

/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

Answer №1

Seems like there's an issue with how the declaration is being used in the plugin. You can manually correct this by updating the path to

/// <reference path="../tns-platform-declarations/android.d.ts" />

from

/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

in index.d.ts

Update:

If you encounter any other TypeScript errors, you can simply add "skipLibCheck": true inside the compilerOptions section of your tsconfig.json.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to display a fragment from one activity while another is also being shown simultaneously?

I am currently facing an issue with navigating between Activity A/Fragment4 and Activity B in my app. While the forward action works perfectly, the back action is causing Activity B and Fragment 4 to appear on the screen simultaneously, indicating that Act ...

What is the process for setting up onBeforeLoad as a command?

I've successfully implemented a script in Cypress that navigates to a specific URL with an onBeforeLoad function: const bomMessage = cy.stub().as('bom'); cy.visit('https://helloworld.com', { onBeforeLoad(win) { win.addEventLi ...

Angular - Enhance User Experience with Persistent Autocomplete Suggestions Displayed

Is there a way to keep the autocomplete panel constantly enabled without needing to specifically focus on the input field? I attempted to set autofocus on the input, but found it to be clunky and the panel could still disappear if I hit escape. I also ...

What are the steps for incorporating a personalized emoticon icon?

In the process of developing an Android instant messaging app for a school, I decided to use Telegram's app code from GitHub. However, I am interested in adding more emote icons to the app. Specifically, I want to create new sets of icons and integrat ...

Issues with BroadcastReceivers and Services

I've set up an app with a MainActivity that doesn't do much, along with a class called BootCompletedIntentReceiver that extends BroadcastReceiver, and another class named MyService that extends Service. My goal is to have the app automatically la ...

Utilizing Vue.js to dynamically render images within a TypeScript array

Currently, I am utilizing Vue 2 together with Typescript and have defined a type in my types.ts file: export type SetupSliderType = { name: SetupSliderEnum; image: HTMLImageElement; title: keyof I18nMessages; component: Function; } No errors are d ...

Switch back emulation when moving away from page - using angular javascript

I have a unique scenario in my component.ts file on a specific page where I need to incorporate custom CSS for printing purposes: @Component({ selector: "dashboard", templateUrl: "./dashboard.component.html", styleUrls: ["./d ...

Odd behavior observed in the Android browser while choosing input fields

When stacking modal elements in the Android Webkit browser (tested on versions 2.2, 2.3, and 3.0), strange behavior seems to occur. Take this example: Here, I have a jQuery UI date picker with z-index 200, a gray overlay div covering the entire document w ...

Encountering the java.lang.NoClassDefFoundError for com.google.firebase.FirebaseOptions despite having Multidex enabled

I am facing an issue with my Android application that uses Firebase and Google Maps. The application works fine on a real device running JellyBean. I have enabled multidex and tried various solutions, but the error persists. Below is the code in my gradle ...

Handling JSON array response in Android

After sending JSON data to the server and receiving a response in JSON format, I am wondering how I can save this returning data as a JSONArray. The response is stored in the 'response' variable. How do I go about saving this response as a JSONAr ...

Distinguishing Features of Protractor Versus Selenium

I am looking to develop an end-to-end testing suite for my Angular application. What are the technical distinctions between creating such a suite using Protractor versus utilizing Selenium (such as Python Selenium or Java Selenium). Both tools are built ...

Issues with Angular's *ngIf directive not functioning correctly

Within my template, I have a block of HTML that controls the visibility of a div. <div *ngIf="csvVisible"> <p>Paragraph works</p> </div> This particular code snippet belongs to my component. export class SettingsComponent imple ...

React Hook Form is flagging missing dependencies in the useEffect function

Before posting this question, I made an effort to search for a solution on Google. However, I am puzzled by the warning that the linter is giving me regarding my code. The warning message reads: ./components/blocks/Contact.tsx 119:6 Warning: React Hook us ...

What is the process for sending a GET request with a URL-encoded object in Angular?

I am struggling with a complex object: { valueA:'a', value_array: { 'v': {value:1, value:2}, 'v2': {value:1, value:2}, } } Is there a way to encode it as a URL string for a GET request using Angular's HTTP servic ...

Using the pipe operator in RXJS to transform an Event into a KeyboardEvent

I'm encountering an error when trying to add a keydown event and convert the parameter type from Event to KeyboardEvent as shown below. fromEvent(document, "keydown") .pipe<KeyboardEvent, KeyboardEvent>( filter((event) => even ...

What is the best location to call the requery() function in order to update the list when a new task is added from a different tab?

I'm developing a straightforward dump and display application. I want the data I input to be shown on the list located in the first tab. However, I'm unsure where to position requery(); Below is the code for the first tab, which displays data fr ...

Discover the steps to update the rows, adjust the number of results, and manage pagination in angular-datatable with an observable as the primary data source

Incorporating angular-datatables into my Angular 7 application has been a challenge, especially when it comes to displaying search results efficiently. Within the request-creation-component, a search form is generated. Upon clicking the submit button, an ...

Serialising and deserialising TypeScript types in local storage

I'm currently working on a Typescript application where I store objects using local storage for development purposes. However, I've run into some trouble with deserialization. Specifically, I have an object called meeting of type MeetingModel: ...

Discovering the data type of interface properties in TypeScript

Consider the following interface along with an object that implements it: interface IData { a: TypeA; b: TypeB; c: boolean; d: string; } const myObject: { data: IData } = { data: { a: valueA, b: valueB, c: t ...

Issue encountered inflating class in Android binary XML file / unable to call on a instance that has been recycled

This issue causes an Android application to crash when running on Android 5 Lollipop, although it functions correctly on Android version 4. The code in question utilizes the AndroidBootstrap library available here. The specific code snippet is as follows: ...