{"record":{"id":"c6542fb825a3ea8b","repo":"oxc-project/oxc","slug":"typescript-will-only-remove-the-inline-type-specif","errorCode":null,"errorMessage":"TypeScript will only remove the inline type specifiers which will leave behind a side effect import at runtime.","messagePattern":"TypeScript will only remove the inline type specifiers which will leave behind a side effect import at runtime\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/no_import_type_side_effects.rs","lineNumber":17,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{ImportDeclarationSpecifier, ImportOrExportKind},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    fixer::Fix,\n    rule::Rule,\n};\n\nfn no_import_type_side_effects_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"TypeScript will only remove the inline type specifiers which will leave behind a side effect import at runtime.\")\n        .with_help(\"Convert this to a top-level type qualifier to properly remove the entire import.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoImportTypeSideEffects;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce the use of top-level `import type` qualifier when an import only\n    /// has specifiers with inline type qualifiers.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// The `--verbatimModuleSyntax` compiler option causes TypeScript to do\n    /// simple and predictable transpilation on import declarations.  Namely, it\n    /// completely removes import declarations with a top-level type qualifier,","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_import_type_side_effects.rs#L1-L35","documentation":"Oxlint's no-import-type-side-effects: for `import { type A } from 'mod'`, TypeScript erases only the inline type specifiers, leaving `import {} from 'mod'` behind as a runtime side-effect module load. The warn text at no_import_type_side_effects.rs:18 states this exactly, and the rule's help recommends the top-level `type` qualifier so the whole statement is removed. The rule registers a Fix (see the Fix import at no_import_type_side_effects.rs:10) to rewrite the statement automatically.","triggerScenarios":"An import declaration where every specifier uses the inline `type` keyword, e.g. `import { type Config, type Options } from './types';`.","commonSituations":"Codebases using verbatimModuleSyntax or isolatedModules, refactors that inline-qualified all specifiers one by one, bundler tree-shaking regressions traced to leftover side-effect imports.","solutions":["Rewrite to `import type { Config, Options } from './types';`","Run `oxlint --fix`; the rule ships an auto-fix for this rewrite","Keep at least one value specifier if the module genuinely must load for side effects"],"exampleFix":"// before\nimport { type Config, type Options } from './types';\n\n// after\nimport type { Config, Options } from './types';","handlingStrategy":"validation","validationCode":"npx oxlint --fix .   # the rule ships a fixer for this exact rewrite\nnpx oxlint --deny-warnings .","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable verbatimModuleSyntax in tsconfig; the compiler then enforces the same discipline","Adopt the habit: if every specifier is a type, the `type` goes on the import itself","Run oxlint --fix in pre-commit so inline-type-only imports are rewritten automatically"],"tags":["typescript","lint","imports","tree-shaking","autofix"],"backgroundTag":"import-type-side-effects","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"}