样式组件 + 打字稿

时间:2021-03-09 18:38:00

标签: reactjs typescript interface styled-components

我在 react app + typescript 中遇到了 eslint 的奇怪问题。我正在使用样式组件,我需要为我的组件创建自定义道具界面,我遵循了文档,当我像文档中的示例一样编写它时,我收到了这个 eslint 错误?有人知道这里发生了什么吗?

'POST'

我的 .eslintrc.js 文件:

customResponseLogic()

eslint 的开发依赖:

registerRoute(
  ({request}) => request.destination === 'image',
  new CacheFirst()
);

registerRoute(
  // Swap this out for whatever criteria you need.
  ({url}) => url.pathname.endsWith('.json'),

  // As before, this assumes that customResponseLogic()
  // takes a FetchEvent and returns a Promise for a Response.
  ({event}) => customResponseLogic(event),

  // Make sure you include 'POST' here!
  'POST'
);

使用最新的 CRA 和 React 脚本。

谢谢

1 个答案:

答案 0 :(得分:0)

这个问题的回答例如在这里:https://stackoverflow.com/a/55439681/10490197 :)

基本上,您使用的规则无法正确理解 TypeScript,因此您需要通过以下方式修复它:

"rules": {
  "no-unused-vars": "off",
  "@typescript-eslint/no-unused-vars": "error"
}