typescript - მხოლოდ ტიპის იმპორტები ეჯახება no-duplicate-imports eslint წესს
მე მაქვს 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(import/no-duplicates)
მოლოდინი მქონდა, რომ eslint უნდა აკმაყოფილებდეს ამ წესს მხოლოდ ტიპის იმპორტებისა და ექსპორტისთვის. არსებობს გზა, რომ შეესაბამოს ეს eslint წესს მას გარეშე დეაქტივაციისა?
პასუხი #1
გამოიყენეთ @typescript-eslint/no-duplicate-imports წესი typescript-eslint პლაგინიდან: https://typescript-eslint.io/rules/no-duplicate-imports/
პასუხი #2
შეგიძლიათ გამოიყენოთ ასე ორივე PropsType და PropsType
import type { PropsType , ImageSrc } from './PropsType';
