{"record":{"id":"a4da102492ca6ec4","repo":"oxc-project/oxc","slug":"remove-void-from-this-union-type-constituent","errorCode":null,"errorMessage":"Remove `void` from this union type constituent.","messagePattern":"Remove `void` from this union type constituent\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/no_invalid_void_type.rs","lineNumber":63,"sourceCode":"    OxcDiagnostic::warn(\"Use `void` only as a return type or as the type of a `this` parameter.\")\n        .with_help(\n            \"Replace this `void` type with an allowed type, or keep `void` only in a valid return position.\",\n        )\n        .with_label(span)\n}\n\nfn invalid_void_not_return_or_this_param_or_generic_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\n        \"Use `void` only as a return type, generic type argument, or the type of a `this` parameter.\",\n    )\n    .with_help(\n        \"Replace this `void` type with an allowed type, or keep `void` only in a valid return position.\",\n    )\n    .with_label(span)\n}\n\nfn invalid_void_union_constituent_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Remove `void` from this union type constituent.\")\n        .with_help(\n            \"Replace this `void` type with an allowed type, or keep `void` only in a valid return position.\",\n        )\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct NoInvalidVoidType(Box<NoInvalidVoidTypeConfig>);\n\n#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]\n#[serde(untagged)]\npub enum AllowInGenericTypeArguments {\n    Boolean(bool),\n    AllowList(Vec<String>),\n}\n\nimpl Default for AllowInGenericTypeArguments {\n    fn default() -> Self {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_invalid_void_type.rs#L45-L81","documentation":"The union-constituent message of no-invalid-void-type: `void` inside a union type (such as `string | void`) is nearly always a mistake because the union cannot express 'maybe undefined' cleanly and assignment behavior surprises readers. The rule asks you to remove it (no_invalid_void_type.rs:64-68).","triggerScenarios":"`type T = string | void;`, `function f(): number | void`, `Promise<void | null>` in positions the config checks.","commonSituations":"Developers mixing up `void` and `undefined` in optional callback chains; refactors that merged return types into unions.","solutions":["Replace `void` in the union with `undefined`","Drop `void` from the union if it was accidental","Keep `void` alone as a bare return type where intended"],"exampleFix":"// before\ntype Result = string | void;\n\n// after\ntype Result = string | undefined;","handlingStrategy":"validation","validationCode":"npx oxlint --deny-warnings .","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Search for `| void` and `void |` when adopting the rule; each hit is `undefined` in disguise","Model optional results as `T | undefined`, never `T | void`","Keep bare `void` return types untouched; only union constituents are the problem"],"tags":["typescript","lint","void","union-type"],"backgroundTag":"invalid-void-type","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"}