ngx-datatable: In ambient enum declarations member initializer must be constant expression
When I import NgxDatatableModule it gives me below list of errors
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/column-mode.type.d.ts (2,16): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/column-mode.type.d.ts (3,12): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/column-mode.type.d.ts (4,13): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/sort.type.d.ts (2,14):In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/sort.type.d.ts (3,13):In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/sort-direction.type.d.ts (2,11): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/sort-direction.type.d.ts (3,12): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (2,14): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (3,13): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (4,18): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (5,12): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (6,16): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/click.type.d.ts (2,14): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/click.type.d.ts (3,14): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/contextmenu.type.d.ts (2,14): In ambient enum declarations member initializer must be constant expression.
ERROR in /Users/manishsharma/My Projects/AngularJS/Prateek/magnitudinis/node_modules/@swimlane/ngx-datatable/release/types/contextmenu.type.d.ts (3,12): In ambient enum declarations member initializer must be constant expression.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 39 (24 by maintainers)
@angun33 Looks like version >= 10.0.0 only work with Angular 5. If you want to use Angular 4 with no warning from Angular cli, then you must use ngx-datatable 9.3.0 or less.
Hi @wizarrc / @jasonhjohnson / @dinvlad
I update the typescript version and using angular 4, and its working like magic for me…
Below is the tweaks I did
└── @swimlane/ngx-datatable@10.2.3And I added both
nameandpropattributes in column configuration, below is the snippetI still have this error.
1>....\node_modules\@swimlane\ngx-datatable\release\types\click.type.d.ts(2,14): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\click.type.d.ts(3,14): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\column-mode.type.d.ts(2,16): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\column-mode.type.d.ts(3,12): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\column-mode.type.d.ts(4,13): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\contextmenu.type.d.ts(2,14): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\contextmenu.type.d.ts(3,12): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\selection.type.d.ts(2,14): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\selection.type.d.ts(3,13): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\selection.type.d.ts(4,18): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\selection.type.d.ts(5,12): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\selection.type.d.ts(6,16): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\sort-direction.type.d.ts(2,11): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\sort-direction.type.d.ts(3,12): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\sort.type.d.ts(2,14): error TS1066: Build:In ambient enum declarations member initializer must be constant expression. 1>....\node_modules\@swimlane\ngx-datatable\release\types\sort.type.d.ts(3,13): error TS1066: Build:In ambient enum declarations member initializer must be constant expression.This are the dependencies
"dependencies": { "@angular/common": "^5.0.3", "@angular/compiler": "^5.0.3", "@angular/core": "^5.0.3", "@angular/forms": "^5.0.3", "@angular/http": "^5.0.3", "@angular/platform-browser": "^5.0.3", "@angular/platform-browser-dynamic": "^5.0.3", "@angular/router": "^5.0.3", "@angular/upgrade": "^5.0.3", "@swimlane/ngx-datatable": "^11.1.4", "bootstrap": "^3.3.7", "chart.js": "^2.7.0", "chart.piecelabel.js": "^0.9.0", "core-js": "^2.5.1", "jquery": "^3.2.1", "ng2-charts": "^1.6.0", "reflect-metadata": "^0.1.10", "rxjs": "^5.4.3", "systemjs": "^0.20.19", "zone.js": "^0.8.17" }, "devDependencies": { "concurrently": "^3.5.0", "del": "^3.0.0", "gulp": "^3.9.1", "gulp-watch": "^4.3.11", "lite-server": "^2.3.0", "typescript": "^2.6.1", "typings": "^2.1.1" },FWIW, Angular 5 seems to be targeting TS 2.4*, not 2.5. So it may be better not to require upwards of 2.5 at this point, if at all possible to rollback. Otherwise, a lot of people may continue being confused by this issue 😉
*https://github.com/angular/angular/commit/ca5aeba
@wizarrc, I already contributed here so you’re preaching to the converted 😃 My preference for this issue though is to wait till the newer versions of TS are officially supported, rather than risk incompatibilities (Angular’s own issue tracker recommends against using even 2.4, as there are still known unresolved ones).
While upgrading to TypeScript 2.4 fixes these errors, it causes the Angular CLI to print out a warning, and according to this comment Angular isn’t compatible with TypeScript 2.4 or 2.5 yet.
@manishsharma1992 someone got the same issue from another repo. https://github.com/swimlane/ngx-ui/issues/95
https://github.com/swimlane/ngx-ui/issues/95#issuecomment-317411663
https://github.com/swimlane/ngx-ui/issues/95#issuecomment-320930688
Hi @wizarrc, Can you apply the hack to repo? So everybody can use ngx-datatable with compatible Typescript version of Angular 4.
@MaxMaes this won’t be a problem in a month once Angular 5 is released. You can always clone the repo and see if you can compile with TypeScript < 2.4. If I got some free time this weekend, I can take a look at what breaks by cloning the repo and recompiling the library with Typescript < 2.4 if it’s not too much of a change to make it compile, I’ll make a PR, and request the change is rolled back in a future release.
Yes, not sure myself (it has actually worked just fine), but I don’t want to risk putting that into production just yet. Also, it may be possible to put a warning into the NPM package for any incompatible upgrades going forward. I can take a look at that in spare time if you’d like.
So what’s a resolution here? We can’t upgrade Typescript to >=2.4 because Angular 4 doesn’t support it. Should we stick to ngx-datatable <=10.0.x?