{"record":{"id":"f5967edf8b64e550","repo":"oxc-project/oxc","slug":"imports-type-imports-are-only-used-as-type","errorCode":null,"errorMessage":"Imports {type_imports} are only used as type.","messagePattern":"Imports (.+?) are only used as type\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/consistent_type_imports.rs","lineNumber":45,"sourceCode":"    OxcDiagnostic::warn(\"`import()` type annotations are forbidden.\")\n        .with_help(\"Replace `import()` type annotations with a regular type import. For example, change `type T = import('module').Type` to `import type { Type } from 'module'; type T = Type`.\")\n        .with_label(span)\n}\n\nfn avoid_import_type_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use an `import` instead of an `import type`.\")\n        .with_help(\"Replace the `import type` declaration with a regular `import` declaration. For example, `import type { Type } from 'module'` would become `import { Type } from 'module'`.\")\n        .with_label(span)\n}\nfn type_over_value_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"All imports in the declaration are only used as types. Use `import type`.\")\n        .with_help(\"Replace the `import` declaration with `import type`. For example, change `import { Type } from 'module'` would become `import type { Type } from 'module'`.\")\n        .with_note(\"Using `import type` for type-only imports helps with tree-shaking, makes it clear that these imports don't affect runtime code, and can improve build performance by allowing bundlers to eliminate unused type imports.\")\n        .with_label(span)\n}\n\nfn some_imports_are_only_types_diagnostic(span: Span, type_imports: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Imports {type_imports} are only used as type.\")).with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct ConsistentTypeImports(Box<ConsistentTypeImportsConfig>);\n\nimpl Deref for ConsistentTypeImports {\n    type Target = ConsistentTypeImportsConfig;\n\n    fn deref(&self) -> &Self::Target {\n        &self.0\n    }\n}\n\n// <https://github.com/typescript-eslint/typescript-eslint/blob/v8.9.0/packages/eslint-plugin/docs/rules/consistent-type-imports.mdx>\n#[derive(Debug, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct ConsistentTypeImportsConfig {\n    /// Disallow using `import()` in type annotations, like `type T = import('foo')`","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/consistent_type_imports.rs#L27-L63","documentation":"Mixed-usage variant of typescript/consistent-type-imports: within one import declaration only some specifiers are used exclusively as types, and their names are interpolated into the message. The expected remedy is the inline `type` modifier on just those specifiers (or splitting the declaration), since converting the whole import would drop the value bindings.","triggerScenarios":"`import { Foo, bar } from './mod';` where Foo appears only in type positions while bar is called or otherwise used as a value. The rule reports the declaration listing Foo in the message.","commonSituations":"Barrel-file style imports mixing types and utilities; refactors that remove the last value usage of one specifier but not others; teams standardizing on inline-type-imports fixStyle during migration.","solutions":["Mark only the type-only specifiers inline: `import { type Foo, bar } from './mod';`","Or split the declaration: `import { bar } from './mod'; import type { Foo } from './mod';`","Apply mechanically with `oxlint --fix` after setting \"fixStyle\": \"inline-type-imports\""],"exampleFix":"// before\nimport { Foo, bar } from './mod';\nlet x: Foo = bar();\n\n// after\nimport { type Foo, bar } from './mod';\nlet x: Foo = bar();","handlingStrategy":"validation","validationCode":"// Codify the inline style so autofix matches team preference:\n// .oxlintrc.json\n{\n  \"rules\": {\n    \"typescript/consistent-type-imports\": [\n      \"warn\", { \"prefer\": \"type-imports\", \"fixStyle\": \"inline-type-imports\" }\n    ]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one fixStyle repo-wide so mixed imports always get the same shape from --fix","Use editor refactors (move to type-only import) instead of hand-editing multi-specifier imports","Keep barrel exports typed so specifiers have clear type vs value roles"],"tags":["typescript","lint","imports","type-import","oxlint"],"backgroundTag":"type-import-style","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}