如何修复错误在Angular 2客户端中找不到名称“对象" [英] How to fix error Cannot find name 'object' in angular 2 cli ckeditor

查看:139
本文介绍了如何修复错误在Angular 2客户端中找不到名称“对象"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用cli安装了ng2-ckeditor:

I have insalled ng2-ckeditor using cli :

npm install ng2-ckeditor --save

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

Then Include CKEditor javascript files in my index file :

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

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

Then imported module in module file:

import { CKEditorModule } from 'ng2-ckeditor';

在导入"CKEditorModule"中

in imports "CKEditorModule"

并尝试在html中使用

and trying to use in html

显示错误:

错误 /var/www/html/eventswebsite/frontendapp/node_modules/ng2-ckeditor/lib/ckeditor.component.d.ts (43,26):找不到名称对象".

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

"ng2-ckeditor/lib/ckeditor.component.d.ts(43,26):找不到名称 对象".

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

如果我改变它的工作 ckeditorInit(config:object)

its working if i change ckeditorInit(config: object)

收件人

ckeditorInit(config:any)

ckeditorInit(config: any)

在npm模块ckeditor组件文件中.

in npm module ckeditor component file.

推荐答案

对于那些正遇到此错误找不到名称'对象'"的人,我发布了此答案,无论他们从哪个组件收到此错误.与TSC编译器版本相关的问题. 对象"是TS2.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.

我正在使用VS 2017社区.默认情况下,它附带了tsc 1.5,即.打字稿编译器版本1.5.我尝试从Nuget更新它,并且还安装了"VS 2017的打字稿",即使我的计算机具有最新的打字稿,但VS打字稿的版本仍为1.5,这无济于事.

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.

然后我搜索了Microsoft最新的VS 2017更新,幸运的是,在VS的顶部栏上找到了最新版本的通知.安装最新更新后,我将VS上的打字稿版本更新为2.2.这样就解决了问题,编译错误也消失了.

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.

作为旁注,您可以在帮助\关于Microsoft Visual Studio"菜单下找到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:

这篇关于如何修复错误在Angular 2客户端中找不到名称“对象"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆