typescript 仅类型导入与无重复导入eslint规则冲突

brccelvz  于 2022-12-30  发布在  TypeScript
关注(0)|答案(1)|浏览(260)

我有一个PropsTypes.ts文件,如下所示:

export interface ImageSrc { url: string; originUrl: string }

export default interface PropsType {
  images: Array<ImageSrc> | Array<string>;
  visible: boolean;
  activeIndex?: number;
  showPagination?: boolean;
  maxScale?: number;
  minScale?: number;
  onChange?: Function;
  onClose?: Function;
}

我使用的是TypeScript 3.8的仅输入和输出功能。

import type PropsType from './PropsType';
import type { ImageSrc } from './PropsType';

但是eslint会抛出一个错误:
多次导入.“/PropsType”。eslint(导入/无重复项)
我期望eslint满足这个只输入类型的导入和导出规则。有没有一种方法可以满足这个eslint规则而不禁用它?

70gysomp

70gysomp1#

使用typescript-eslint插件中的@typescript-eslint/no-duplicate-imports规则:https://typescript-eslint.io/rules/no-duplicate-imports/

相关问题