【发布时间】:2017-08-17 17:22:00
【问题描述】:
我正在开发一个Angular 项目,最近安装了ng2-dropdown-treeview 1.0.5。安装后,我用npm start重新启动了我的服务器。
我的服务器日志正在打印以下错误:
[PATH]\node_modules\@types\node\index.d.ts:82:13
Subsequent variable declarations must have the same type. Variable 'module' must be of type 'any', but here has type 'NodeModule'.
根据错误,我导航到 index.d.ts:82 并将 declare var module: NodeModule; 更改为 declare var module: any。
但这导致我的 devtools 控制台出现错误:
Uncaught TypeError: ctorParameters.map is not a function.
它指向 vendor.bundle.js.35429:
// API of tsickle for lowering decorators to properties on the class.
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__facade_lang__["e" /* isPresent */])(typeOrFunc.ctorParameters)) {
var ctorParameters = typeOrFunc.ctorParameters;
var paramTypes_1 = ctorParameters.map(function (ctorParam /** TODO #9100 */) { return ctorParam && ctorParam.type; });
var paramAnnotations_1 = ctorParameters.map(function (ctorParam /** TODO #9100 */) {
return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators);
});
return this._zipTypesAndAnnotations(paramTypes_1, paramAnnotations_1);
我已经反对像这样更改打包代码,所以我想我会问其他人是否有类似的问题。非常感谢任何帮助!
【问题讨论】:
-
看起来您的
.d.tss 之一中可能有重复的变量 def。你包括了什么类型的defs?你能把问题减少到使用最少数量的模块吗? -
@SandyGifford,感谢您的参与。我在 custom-types.d.ts 中有
declare module '*';,这是我认为可能存在冲突的唯一地方。但是既然是通配符,应该不会冲突吧?即便如此,为了安全起见,我还是将其更改为declare var module: any;,但它仍然给我同样的问题:( -
这可能会导致问题。您可以尝试仅使用这两个 def 和足够的代码来在新项目中重新创建问题吗?
-
所以,原来问题与ng2-dnd的冲突有关。一旦我删除了对 ng2-dnd 的所有引用,并更改了
declare var module: any,问题就解决了。 -
有意思,可能是
.d.ts的问题?
标签: angular typescript npm npm-install