【发布时间】:2019-03-29 13:55:48
【问题描述】:
我已按照here 的官方升级手册将我的 Angular 项目升级到最新版本。当我在项目文件夹中运行“ng serve”时出现错误
"ERROR in src/app/menu/menu-tree.component.ts(93,63): error TS2339: Property 'localName' does not exist on type 'Node'.
我在 lib.dom.d.ts 中找到了 Node 类型的定义(完整路径:C:\Users\my_user\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\ typescript\lib\lib.dom.d.ts)。
这里是受影响的代码:
if ( mutation.type === 'childList' && mutation.target.localName === 'span' &&
mutation.addedNodes.length > 0 && mutation.removedNodes.length === 0) {
lib.dom.d.ts 中接口 MutationRecord 中属性“target”的定义:
readonly target: Node;
【问题讨论】:
-
安装了什么打字稿版本?你从/到哪个版本?
-
实际版本:3.2.4。在升级之前它可能是 2.5.3(package.json 中的“~2.5.3”)。
-
谢谢@OneLunchMan。我一直在寻找对“localName”属性的任何引用。
标签: angular typescript