代码之家  ›  专栏  ›  技术社区  ›  Lin Du Correcter

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

  •  0
  • Lin Du Correcter  · 技术社区  · 4 年前

    我有一个 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;
    }
    

    我正在使用 type-only-imports-and-export TypeScript 3.8的特性。

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

    但是eslint会抛出一个错误:

    './多次导入PropsType。eslint(导入/无重复项)

    我希望eslint应该满足仅输入类型的导入和导出的规则。 有没有一种方法可以在不禁用它的情况下满足这个eslint规则?

    0 回复  |  直到 2 年前
        1
  •  0
  •   Matt Leonowicz    2 年前

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

    推荐文章