This rule aims to standardize the use of type imports style across the codebase.
import type { Foo } from './foo';
let foo: Foo;
import { Foo } from './foo';
let foo: Foo;
let foo: import('foo').Foo;
type Options =
| 'type-imports'
| 'no-type-imports'
| {
prefer: 'type-imports' | 'no-type-imports';
disallowTypeAnnotations: boolean;
};
const defaultOptions: Options = {
prefer: 'type-imports',
disallowTypeAnnotations: true,
};
This option defines the expected import kind for type-only imports. Valid values for prefer
are:
type-imports
will enforce that you always useimport type Foo from '...'
. It is default.no-type-imports
will enforce that you always useimport Foo from '...'
.
If true
, type imports in type annotations (import()
) is not allowed.
Default is true
.
If you specifically want to use both import kinds for stylistic reasons, you can disable this rule.