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

时间:2022-07-24
本文章向大家介绍n ../../node_modules/@storybook/channels/dist/index.d.ts:25:9 - error TS1086: An accessor cannot ...,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

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

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, 即可解决问题

{
  "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"
    ]
  },
}