Search code examples
angularionic-frameworkngx-datatableionic5

ngx-datatable An accessor cannot be declared in an ambient context


I am facing an error while trying to add ngx-datatable in to my ionic + angular project. I am receiving hundereds of error lines and it seems it doesn't add ngx-database into my project. I am following Add ngx-datatable with ionic 5 to add ngx-datatable into my project.

package.json

"@angular/common": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"@ionic-native/core": "^5.0.7",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^5.0.0",
"@swimlane/ngx-datatable": "^17.0.0",
"core-js": "^2.5.4",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"

in app/home.module.ts

import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { HomePage } from './home.page';
import { HomePageRoutingModule } from './home-routing.module';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    HomePageRoutingModule, NgxDatatableModule
  ],
  declarations: [HomePage],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class HomePageModule {}

and the errors

ERROR in node_modules/@swimlane/ngx-datatable/lib/components/body/body-cell.component.d.ts:8:9 - error TS1086: An accessor cannot be declared in an ambient context.
[ng] 8     set group(group: any);

node_modules/@swimlane/ngx-datatable/lib/components/body/body-cell.component.d.ts:9:9 - error TS1086: An accessor cannot be declared in an ambient context.
[ng] 9     get group(): any;

I guess my version of ionic+angular is not compatible or ngx-datatable is not compatable or any other errors which I am struggling with.


Solution

  • Solved it. ngx-datatable version 17.0.0 was not compatible with the ionic + angular versions I have in the package.json file. I simply installed ngx-datatable 16.1.1 version and that solved the problem.

    npm i @swimlane/ngx-datatable@16.1.1 --save