# import/consistent-type-specifier-style

> Enforce one way to mark type-only imports: `import type { A }` or `import { type A }`

TypeScript has two ways to mark an import as type-only: `import type { User }` for the whole statement, or `import { type User }` for one name. This rule keeps a project on one of them.

The two compile differently with `verbatimModuleSyntax`. `import type { User } from "./user"` is removed, while `import { type User } from "./user"` is left as `import {} from "./user"` and still loads the module.

By default the rule asks for `import type`. Imports without braces, such as `import type User from "./user"`, are never reported.

`--fix` rewrites the import in the style you chose.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"import/consistent-type-specifier-style" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
# "prefer-inline" or "prefer-top-level"
"import/consistent-type-specifier-style" = ["error", "prefer-top-level"]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```ts
import { type User, type Session } from "./models";
```

{/* bad */}
```ts
import { createUser, type User } from "./models";
```

Not reported:

{/* good */}
```ts
import type { User, Session } from "./models";
```

{/* good */}
```ts
import { createUser } from "./models";
import type { User } from "./models";
```

## Options

```toml bunfig.toml
[lint.rules]
"import/consistent-type-specifier-style" = ["error", "prefer-inline"]
```

| Option | What it does |
| --- | --- |
| `"prefer-top-level"` (default) | Report `import { type User }`. Types go in their own `import type` statement. |
| `"prefer-inline"` | Report `import type { User }`. Each type is marked by name, so one import statement per module is enough. |

{/* bad {"options": ["prefer-inline"]} */}
```ts
import { createUser } from "./models";
import type { User } from "./models";
```

{/* good {"options": ["prefer-inline"]} */}
```ts
import { createUser, type User } from "./models";
```
