Skip to main content


Enforce consistent usage of type exports.


此规则报告的一些问题可通过 --fix ESLint 命令行选项自动修复


该规则需要 类型信息 才能运行。

TypeScript 允许在导出上指定 type 关键字,以指示导出仅存在于类型系统中,而不存在于运行时。 这允许转译器在不知道依赖类型的情况下删除导出。

英:TypeScript allows specifying a type keyword on exports to indicate that the export exists only in the type system, not at runtime. This allows transpilers to drop exports without knowing the types of the dependencies.

详细信息请参见 博客 > 一致类型导出和导入:原因和方式

module.exports = {
"rules": {
"@typescript-eslint/consistent-type-exports": "error"
在线运行试试这个规则 ↗


interface ButtonProps {
onClick: () => void;

class Button implements ButtonProps {
onClick = () => console.log('button!');

export { Button, ButtonProps };
Open in Playground



当此项设置为 true 时,规则将使用 TS 4.5 的 "内联类型说明符" 自动修复 "mixed" 导出案例。 如果你使用的 TypeScript 版本低于 4.5,那么你将无法使用此选项。

英:When this is set to true, the rule will autofix "mixed" export cases using TS 4.5's "inline type specifier". If you are using a TypeScript version less than 4.5, then you will not be able to use this option.


英:For example the following code:

const x = 1;
type T = number;

export { x, T };

{fixMixedExportsWithInlineTypeSpecifier: true} 将被固定为:

英:With {fixMixedExportsWithInlineTypeSpecifier: true} will be fixed to:

const x = 1;
type T = number;

export { x, type T };

{fixMixedExportsWithInlineTypeSpecifier: false} 将被固定为:

英:With {fixMixedExportsWithInlineTypeSpecifier: false} will be fixed to:

const x = 1;
type T = number;

export type { T };
export { x };
export { Button } from 'some-library';
export type { ButtonProps } from 'some-library';
Open in Playground


如果使用 --isolatedModules,如果未使用 export type 重新导出类型,编译器将出错。 在这些情况下,该规则可能不太有用。

英:If you use --isolatedModules the compiler would error if a type is not re-exported using export type. This rule may be less useful in those cases.


英:If you specifically want to use both export kinds for stylistic reasons, or don't wish to enforce one style over the other, you can avoid this rule.

但是,请记住,不一致的风格可能会损害项目的可读性。 我们建议为此规则选择一个最适合你的项目的选项。

英:However, keep in mind that inconsistent style can harm readability in a project. We recommend picking a single option for this rule that works best for your project.



type Options = [
fixMixedExportsWithInlineTypeSpecifier?: boolean;

const defaultOptions: Options = [
{ fixMixedExportsWithInlineTypeSpecifier: false },