【问题标题】:Calling function 'makeDecorator', function calls are not supported调用函数'makeDecorator',不支持函数调用
【发布时间】:2018-03-28 10:42:28
【问题描述】:

由@alexzuza 解决。请参阅下面的答案-大惊小怪! 基本上,从 ng2-opd-popup 文件夹中删除 node_modules 文件夹,然后编辑 src/tsconfig.app.json 以匹配路径。另请参阅 cmets 以获取 rimraf 设置的链接,以自动排除 node_modules 与 npm install 一起安装。

我收到此错误:

错误中的错误遇到静态解析符号值。打电话 函数“makeDecorator”,不支持函数调用。考虑 将函数或 lambda 替换为对导出的引用 功能

找到的解决方案 here 不起作用 - 我正在运行 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/*。可能还有其他方法可以修复它,但我不确定。
  • 真是太可惜了,这个包裹看起来不错。您对其他模态包有什么建议吗?

标签: json angular typescript npm simplemodal


【解决方案1】:

改变 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 folder

【讨论】:

  • 仍然收到错误 mate :( 你有这个包在 Angular 4.3 上工作吗?
  • 是的,它对我有用。请创建最小的 repo 来重现它
  • 对不起,我不知道该怎么做。但这不是必需的,我只需要使用路径编辑 tsconfig.json 和 tsconfig.app.json 文件 - 对吧?
  • 如果是,则仅在 src/tsconfig.app.json 中添加 paths 选项,正如我在回答中所写的那样
  • 如果我使用cli,我不需要编辑src/tsconfig.json?
猜你喜欢
  • 2017-09-20
  • 2018-02-04
  • 2017-06-06
  • 2017-07-14
  • 2017-06-08
  • 2018-06-11
  • 2017-03-30
  • 1970-01-01
相关资源
最近更新 更多