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

时间:2017-10-16 20:09:37

标签: json angular typescript npm simplemodal

由@alexzuza解决。看下面他的答案 - 大人物! 基本上,从ng2-opd-popup文件夹中删除node_modules文件夹,然后编辑src/tsconfig.app.json以匹配路径。请参阅注释以获取有关rimraf设置的链接,以自动排除使用npm install安装的node_modules。

我收到此错误:

  

ERROR in Error遇到静态解析符号值。调用   函数'makeDecorator',不支持函数调用。考虑   使用对导出的引用替换函数或lambda   功能

找到here的解决方案无效 - 我正在运行角度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"
    ]
  }
}

我的文件结构。 File structure

我试图使用的包:ng2-opd-popup

有人为此获得了解决方案,或者可能使用更好的软件包吗?

1 个答案:

答案 0 :(得分:4)

更改 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

enter image description here