Ngx-table angular2 swimlane com 编译问题
Ngx-table angular2 swimlane com compilation issue
我正在尝试使用 ngx-datatable,但在安装后出现编译错误。我从最近几个小时开始就在搜索这个问题,但不知道是什么原因造成的。
- 使用通常的方式安装它:
npm install
@swimlane/ngx-datatable
- 导入模块
app.module.ts
import { NgxDatatableModule } from '@swimlane/ngx-datatable
imports: [
NgxDatatableModule,
BrowserModule]
HTML :
<ngx-datatable
class="material striped"
[rows]="rows"
[columns]="columns">
</ngx-datatable>
ERROR in
my-package
/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
my-package
/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
my-package
/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
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort.type.d.ts
(2,14): In ambient enum declar ations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort.type.d.ts
(3,13): In ambient enum declar ations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort-direction.type.d.ts
(2,11): In ambient e num declarations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort-direction.type.d.ts
(3,12): In ambient e num declarations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts
(2,14): In ambient enum d eclarations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts
(3,13): In ambient enum d eclarations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts
(4,18): In ambient enum d eclarations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts
(5,12): In ambient enum d eclarations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts
(6,16): In ambient enum d eclarations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/click.type.d.ts
(2,14): In ambient enum decla rations member initializer must be
constant expression.
ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/click.type.d.ts
(3,14): In ambient enum decla rations member initializer must be
constant expression.
ERROR in
my-package
/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
my-package
/node_modules/@swimlane/ngx-datatable/release/types/contextmenu.type.d.ts
(3,12): In ambient enum declarations member initializer must be
constant expression.
感谢帮助。
这是他们 Github 页面上的问题:https://github.com/swimlane/ngx-datatable/issues/927
似乎更新到 Typescript 2.4 可能会解决问题(对我来说是这样)。当然,请记住,应该根据您使用的工具在 npm and/or Visual Studio 中更新它。
这个答案解决了我的问题(我在 https://github.com/swimlane/ngx-datatable/issues/927 中找到它):
- 打开package.json并删除定义打字稿的行
依赖及其版本
- 删除 node_modules 文件夹
- 删除包-lock.json 文件(如果您使用 NPM 5+)
- 运行 npm install typescript@latest --save
- 运行 npm 安装
我正在尝试使用 ngx-datatable,但在安装后出现编译错误。我从最近几个小时开始就在搜索这个问题,但不知道是什么原因造成的。
- 使用通常的方式安装它:
npm install @swimlane/ngx-datatable
- 导入模块
app.module.ts
import { NgxDatatableModule } from '@swimlane/ngx-datatable
imports: [
NgxDatatableModule,
BrowserModule]
HTML :
<ngx-datatable
class="material striped"
[rows]="rows"
[columns]="columns">
</ngx-datatable>
ERROR in
my-package
/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
my-package
/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
my-package
/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
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort.type.d.ts (2,14): In ambient enum declar ations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort.type.d.ts (3,13): In ambient enum declar ations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort-direction.type.d.ts (2,11): In ambient e num declarations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/sort-direction.type.d.ts (3,12): In ambient e num declarations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (2,14): In ambient enum d eclarations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (3,13): In ambient enum d eclarations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (4,18): In ambient enum d eclarations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (5,12): In ambient enum d eclarations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/selection.type.d.ts (6,16): In ambient enum d eclarations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/click.type.d.ts (2,14): In ambient enum decla rations member initializer must be constant expression.ERROR in
my-package
/node_modules/@swimlane/ngx-datatable/release/types/click.type.d.ts (3,14): In ambient enum decla rations member initializer must be constant expression.ERROR in
my-package
/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
my-package
/node_modules/@swimlane/ngx-datatable/release/types/contextmenu.type.d.ts (3,12): In ambient enum declarations member initializer must be constant expression.
感谢帮助。
这是他们 Github 页面上的问题:https://github.com/swimlane/ngx-datatable/issues/927
似乎更新到 Typescript 2.4 可能会解决问题(对我来说是这样)。当然,请记住,应该根据您使用的工具在 npm and/or Visual Studio 中更新它。
这个答案解决了我的问题(我在 https://github.com/swimlane/ngx-datatable/issues/927 中找到它):
- 打开package.json并删除定义打字稿的行 依赖及其版本
- 删除 node_modules 文件夹
- 删除包-lock.json 文件(如果您使用 NPM 5+)
- 运行 npm install typescript@latest --save
- 运行 npm 安装