如何修正在角2 cli ditor中找不到名称'object'的错误

时间:2021-01-05 17:07:08

I have insalled ng2-ckeditor using cli :

我已经注册了使用cli的ng2-ckeditor:

npm install ng2-ckeditor --save

Then Include CKEditor javascript files in my index file :

然后在我的索引文件中包含CKEditor javascript文件:

<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>

Then imported module in module file:

然后在模块文件中导入模块:

import { CKEditorModule } from 'ng2-ckeditor';

in imports "CKEditorModule"

进口“CKEditorModule”

and trying to use in html

并尝试在html中使用

It show error:

它显示错误:

ERROR in /var/www/html/eventswebsite/frontendapp/node_modules/ng2-ckeditor/lib/ckeditor.component.d.ts (43,26): Cannot find name 'object'.

在/var/www/html/eventswebsite/frontendapp/node_modules/ng2-ckeditor/lib/ ckeditor.t .component.d.ts(43,26)中出现错误:无法找到名称'object'。

"ng2-ckeditor/lib/ckeditor.component.d.ts (43,26): Cannot find name 'object'."

“ng2-ckeditor/lib/ckeditor.component.d.ts(43,26):无法找到名称'object'。”

its working if i change ckeditorInit(config: object)

如果我改变了ckeditorInit(config: object)

To

ckeditorInit(config: any)

ckeditorInit(配置:任何)

in npm module ckeditor component file.

在npm模块中,ckeditor组件文件。

1 个解决方案

#1


2  

I am posting this answer for those who are facing this error "Cannot find name 'object'" irrespective of which component they are getting this error in. This is a tsc compiler version related issue. 'object' is keyword in TS2.2.

对于那些面临这个错误的人,我将给出这个答案,“无论他们在哪个组件中得到这个错误,都找不到名称'object'”。这是一个tsc编译器版本相关的问题。“object”是TS2.2中的关键词。

I am using VS 2017 Community. By default it shipped with tsc 1.5 ie. typescript compiler version 1.5. I tried updating it from Nuget and also installed "typescript for VS 2017" nothing helped, even though my computer had latest version of typescript, but VS typescript version was still 1.5.

我正在使用VS 2017社区。默认情况下,它附带tsc 1.5 ie。打印稿编译器1.5版。我试着从Nuget上更新它,还安装了“VS 2017的打字稿”,但没有任何帮助,尽管我的电脑上有最新的打字稿版本,但VS打字稿版本仍然是1.5。

Then I searched for Microsoft's latest update of VS 2017, fortunately for me notification of latest release was found on top bar of VS. After installing the latest update I got my typescript version on VS updated to 2.2. This resolved the issue and compilation errors were gone.

然后我搜索了微软最新的VS 2017更新,幸运的是在VS的顶部栏找到了最新版本的通知。这解决了问题,编译错误消失了。

As a side note, you can find the version of typescript VS is using under menu "Help\About Microsoft Visual Studio", then on pop up screen scroll down a bit as shown in below image:如何修正在角2 cli ditor中找不到名称'object'的错误

作为补充说明,您可以在“关于Microsoft Visual Studio的帮助\”菜单下找到打字稿VS正在使用的版本,然后在弹出的屏幕上向下滚动一点,如下图所示:

#1


2  

I am posting this answer for those who are facing this error "Cannot find name 'object'" irrespective of which component they are getting this error in. This is a tsc compiler version related issue. 'object' is keyword in TS2.2.

对于那些面临这个错误的人,我将给出这个答案,“无论他们在哪个组件中得到这个错误,都找不到名称'object'”。这是一个tsc编译器版本相关的问题。“object”是TS2.2中的关键词。

I am using VS 2017 Community. By default it shipped with tsc 1.5 ie. typescript compiler version 1.5. I tried updating it from Nuget and also installed "typescript for VS 2017" nothing helped, even though my computer had latest version of typescript, but VS typescript version was still 1.5.

我正在使用VS 2017社区。默认情况下,它附带tsc 1.5 ie。打印稿编译器1.5版。我试着从Nuget上更新它,还安装了“VS 2017的打字稿”,但没有任何帮助,尽管我的电脑上有最新的打字稿版本,但VS打字稿版本仍然是1.5。

Then I searched for Microsoft's latest update of VS 2017, fortunately for me notification of latest release was found on top bar of VS. After installing the latest update I got my typescript version on VS updated to 2.2. This resolved the issue and compilation errors were gone.

然后我搜索了微软最新的VS 2017更新,幸运的是在VS的顶部栏找到了最新版本的通知。这解决了问题,编译错误消失了。

As a side note, you can find the version of typescript VS is using under menu "Help\About Microsoft Visual Studio", then on pop up screen scroll down a bit as shown in below image:如何修正在角2 cli ditor中找不到名称'object'的错误

作为补充说明,您可以在“关于Microsoft Visual Studio的帮助\”菜单下找到打字稿VS正在使用的版本,然后在弹出的屏幕上向下滚动一点,如下图所示: