调用函数'makeDecorator',不支持函数调用。

3

由@alexzuza解决。请参阅他下面的答案-大力支持!

基本上,从ng2-opd-popup文件夹中删除node_modules文件夹,并编辑src/tsconfig.app.json以匹配路径。另请参阅注释以获取rimraf设置的链接,以自动排除使用npm install安装node_modules。

我遇到了这个错误:

错误:在静态解析符号值时遇到错误。调用函数'makeDecorator',不支持函数调用。考虑将该函数或lambda替换��对导出函数的引用

此处找到的解决方案不起作用-我正在运行angular v. 4.3。

package.json:

PopupModule.forRoot(),

tsconfig.json:

"paths": {
  "@angular/*": ["node_modules/@angular/*"]
},

tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "paths": {
      "@angular/common": ["../node_modules/@angular/common"],
      "@angular/compiler": ["../node_modules/@angular/compiler"],
      "@angular/core": ["../node_modules/@angular/core"],
      "@angular/forms": ["../node_modules/@angular/forms"],
      "@angular/platform-browser": ["../node_modules/@angular/platform-browser"],
      "@angular/platform-browser-dynamic": ["../node_modules/@angular/platform-browser-dynamic"],
      "@angular/router": ["../node_modules/@angular/router"],
      "@angular/http": ["../node_modules/@angular/http"]
    },
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

tsconfig.app.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "paths": {
      "@angular/*": ["../node_modules/@angular/*"]
    },
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

我的文件结构。 文件结构

我正在尝试使用的包:ng2-opd-popup

有人有解决方案吗?或者还有更好的包可以使用吗?


问题出在 ng2-opd-popup 上,不幸的是。您可以手动复制 TypeScript 代码到本地项目中进行构建。要修复该模块,他们必须在构建过程中从 dependencies 中删除 @angular/*。可能还有其他方法来解决它,但我不确定。 - Explosion Pills
真遗憾,这个包看起来很不错。你有其他模态包的建议吗? - blixenkrone
1个回答

5

更改 src/tsconfig.app.json 如下:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": [],
    "paths": {
      "@angular/*": ["../node_modules/@angular/*"] <=== add this
    }
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

您应该使用 ..,因为baseUrl是指src文件夹

https://github.com/alexzuza/angular-cli-make-decorator-fix

这对 aot 应该有效,但对于 jit 模式,您需要删除 node_modules/ng2-opd-popup/node_modules 文件夹

enter image description here


仍然出现错误,伙计 :( 你之前在 Angular 4.3 上使用过这个包吗? - blixenkrone
是的,对我来说它有效。请创建最小的仓库以重现它。 - yurzui
如果是的话,只需按照我在答案中写的那样,在 src/tsconfig.app.json 中添加 paths 选项。 - yurzui
如果我使用CLI,我不需要编辑src/tsconfig.json吗? - blixenkrone
仅编辑 src/tsconfig.app.json 仍无法正常运行。 - blixenkrone
显示剩余12条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接