n ../../node_modules/@storybook/channels/dist/index.d.ts:25:9 - error TS1086: An accessor cannot ...

2020-08-28 15:16:09 浏览数 (1)

如题,在开发angular插件的时候发现报了如题错误

代码语言:javascript复制
n ../../node_modules/@storybook/channels/dist/index.d.ts:25:9 - error TS1086: An accessor cannot be declared in an ambient context.
原因

因为angular版本不匹配。 插件库用的typescript版本为3.8.3,在使用项目中typescript版本为3.5.3所以导致了出现如上的错误。

解决办法

尝试在tsconfig.json中配置 "skipLibCheck" :true, 即可解决问题

代码语言:javascript复制
{
  "compilerOptions": {
    "baseUrl": "src",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",

    **"skipLibCheck": true,**

    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  },
}

0 人点赞