如何修复错误无法在 angular 2 单击 ckeditor 中找到名称“对象" [英] How to fix error Cannot find name 'object' in angular 2 cli ckeditor

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

问题描述

我使用 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(配置:对象)

its working if i change ckeditorInit(config: object)

ckeditorInit(config: any)

ckeditorInit(config: any)

在 npm 模块 ckeditor 组件文件中.

in npm module ckeditor component file.

推荐答案

我为那些遇到此错误无法找到名称‘对象’"的人发布此答案,无论他们在哪个组件中遇到此错误.这是与 tsc 编译器版本相关的问题.'object' 是 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.

然后我搜索了微软最新的 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.

作为旁注,您可以在菜单Help\About 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 单击 ckeditor 中找到名称“对象"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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