export { User } from "./models" doesn't say whether User is a type or a value. A tool that compiles one file at a time can't open ./models to find out whether to keep the export or drop it. export type { User } spells it out. The export is a type, and it's removed from the JavaScript output.
--fix adds the type keyword.
Configure
Off by default. This rule needs types, so turning it on makes bun lint type check your code first.
[lint.rules]
"@typescript-eslint/consistent-type-exports" = "error" # or "warn"
Every option, set to its default:
[lint.rules]
"@typescript-eslint/consistent-type-exports" = ["error", {
fixMixedExportsWithInlineTypeSpecifier = false,
}]
Examples
Reported:
interface User {
name: string;
}
export { User };
export interface User {
name: string;
}
export type Id = string;
export { User } from "./models";
export * from "./models";
Not reported:
interface User {
name: string;
}
const admin: User = { name: "Ada" };
export type { User };
export { admin };
Options
| Option | Default | What it does |
|---|---|---|
fixMixedExportsWithInlineTypeSpecifier | false | How --fix repairs an export that mixes types and values. |
An export that mixes the two is reported with either setting:
interface User {
name: string;
}
const admin: User = { name: "Ada" };
export { User, admin };
With false, --fix splits it into export type { User } and export { admin }. With true, it marks the type inside the braces. Both forms are accepted with either setting.
interface User {
name: string;
}
const admin: User = { name: "Ada" };
export { type User, admin };