src/content/docs/linter/rules/use-export-type.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="TypeScript and TSX" icon="seti:typescript"> ## Summary - Rule available since: `v1.5.0` - Diagnostic Category: [`lint/style/useExportType`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has a [**safe**](/linter/#safe-fixes) fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Inspired from [`@typescript-eslint/consistent-type-exports`](https://typescript-eslint.io/rules/consistent-type-exports){
"linter": {
"rules": {
"style": {
"useExportType": "error"
}
}
}
}
Promotes the use of export type for types.
TypeScript allows adding the type keyword on an export to indicate that the export doesn't exist at runtime.
This allows compilers to safely drop exports of types without looking for their definition.
The rule ensures that types are exported using a type-only export.
It also groups inline type exports into a grouped export type.
interface I {}
export { I };
type T = number;
export { T };
import type { T } from "./mod.js";
export { T };
export { type X, type Y };
class C {}
function f() {}
export { C, f };
This rules checks only the identifiers that are defined in a file. It doesn't warn against a type exported as a value in a re-export clause such as:
export { TypeA } from "./mod.ts"