{"record":{"id":"cb0b8ac912eb7a95","repo":"oxc-project/oxc","slug":"use-ts-expect-error-instead-of-ts-ignore-as","errorCode":null,"errorMessage":"Use \"@ts-expect-error\" instead of @ts-ignore, as \"@ts-ignore\" will do nothing if the following line is error-free.","messagePattern":"Use \"@ts-expect-error\" instead of @ts-ignore, as \"@ts-ignore\" will do nothing if the following line is error-free\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs","lineNumber":24,"sourceCode":"use schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n    utils::deserialize_required_regex_option,\n};\n\nfn comment(ts_comment_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Do not use @ts-{ts_comment_name} because it alters compilation errors.\"\n    ))\n    .with_help(format!(\"Remove the @ts-{ts_comment_name} directive and fix the underlying TypeScript error instead. If you must suppress an error, consider using @ts-expect-error with a descriptive comment explaining why it's necessary.\"))\n    .with_label(span)\n}\n\nfn ignore_instead_of_expect_error(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use \\\"@ts-expect-error\\\" instead of @ts-ignore, as \\\"@ts-ignore\\\" will do nothing if the following line is error-free.\")\n        .with_help(\"Replace \\\"@ts-ignore\\\" with \\\"@ts-expect-error\\\".\")\n        .with_label(span)\n}\n\nfn comment_requires_description(ts_comment_name: &str, min_len: u64, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"Include a description after the @ts-{ts_comment_name} directive to explain why the @ts-{ts_comment_name} is necessary. The description must be {min_len} characters or longer.\"\n    ))\n    .with_help(format!(\"Add a description after @ts-{ts_comment_name} that is at least {min_len} characters long, explaining why the directive is necessary. For example: `// @ts-{ts_comment_name}: TS2345 - This is a known limitation with third-party types`\"))\n    .with_note(\"Requiring descriptions ensures that developers document why they're suppressing TypeScript errors, making it easier for future maintainers to understand the context and decide if the suppression is still necessary.\")\n    .with_label(span)\n}\n\nfn comment_description_not_match_pattern(\n    ts_comment_name: &str,\n    pattern: &str,\n    span: Span,\n) -> OxcDiagnostic {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/ban_ts_comment.rs#L6-L42","documentation":"Second diagnostic of oxlint's ban-ts-comment rule. When `ts-ignore` is configured as `\"allow-with-description\"` but the comment has no (or too-short) description, this message nudges you to `@ts-expect-error` instead. The reason: @ts-ignore suppresses whatever is on the next line and silently does nothing once that line becomes error-free, while @ts-expect-error turns into a compile error when its suppression becomes stale — fail-loud instead of fail-silent.","triggerScenarios":"Config contains `{ \"ts-ignore\": \"allow-with-description\" }` (or a descriptionFormat variant) and source has a bare `// @ts-ignore` with no trailing description, or one shorter than minimumDescriptionLength (default 3). The default configuration never produces this message (default ts-ignore is simply banned → the generic 'Do not use' diagnostic).","commonSituations":"Teams that softened the ban to allow-with-description to unblock a migration and still write naked @ts-ignore; long-lived suppressions nobody dares delete; code review wants a reason on every suppression line.","solutions":["Replace `// @ts-ignore` with `// @ts-expect-error: <reason ≥ minimumDescriptionLength chars>`.","Verify the next line still has an error after switching — @ts-expect-error fails compilation if it does not (which is the point).","Better: fix the underlying error and remove the directive entirely.","If a regex governs the description shape (descriptionFormat), match it, e.g. `: TS2345 because <reason>`."],"exampleFix":"// before\n// @ts-ignore\nlegacyAssign(target, source);\n\n// after\n// @ts-expect-error: TS2345 - third-party types lack the v2 field until the next release\nlegacyAssign(target, source);","handlingStrategy":"validation","validationCode":"oxlint --ts-plugin src/ # with { \"ts-ignore\": \"allow-with-description\" } configured","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer @ts-expect-error over @ts-ignore everywhere — stale suppressions then fail the build instead of rotting.","Write descriptions that name the error code and reason (e.g. 'TS2345 - vendor types lack field X').","Raise minimumDescriptionLength if one-word descriptions keep slipping through."],"tags":["typescript","ts-ignore","ts-expect-error","suppression","oxlint","lint"],"backgroundTag":"ts-comment-suppression","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}