Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,15 @@ fn is_nullable_boolean(t: P<Type>) -> bool {
if !t.flags().intersects(TypeFlags::Union) {
return false;
}
let flags = t.types().iter().fold(TypeFlags::None, |flags, part| flags | part.flags());
flags.intersects(TypeFlags::Nullable) && flags.intersects(TypeFlags::BooleanLike)
let parts = t.types();
let is_nullish =
|part: &P<Type>| part.flags().intersects(TypeFlags::Undefined | TypeFlags::Null);
parts.iter().any(is_nullish)
&& !parts.iter().all(is_nullish)
&& parts
.iter()
.filter(|part| !is_nullish(part))
.all(|part| part.flags().intersects(TypeFlags::BooleanLike))
}

fn get_boolean_comparison(
Expand Down
2 changes: 1 addition & 1 deletion crates/tsrs_lint/tests/baselines/PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ and suggestions before its implementation commit. Upstream skips remain explicit
| no-misused-spread | Updated to Go HEAD | 133 current cases, 1 upstream skips; string/array/iterable/class checks, allowlists, await and map suggestions |
| no-mixed-enums | Updated to ddba56df | 54 current cases; initializer types, merged declarations, empty or non-enum earlier declarations, enums without symbols and namespace/module augmentation |
| no-redundant-type-constituents | Updated to Go HEAD | 104 current cases; union/intersection overrides, aliases, literals and function return exceptions |
| no-unnecessary-boolean-literal-compare | Updated to Go HEAD | 50 current cases; nullable options, unary/precedence fixes and strictNullChecks diagnostics |
| no-unnecessary-boolean-literal-compare | Updated to ada797a9 | 51 current cases; boolean-only nullable unions, nullable options, unary/precedence fixes and strictNullChecks diagnostics |
| no-unnecessary-condition | Updated to Go HEAD | 384 current cases; truthiness, nullish checks, optional chains, comparisons, loops and predicates |
| no-unnecessary-qualifier | Updated to Go HEAD | 18 current cases; namespace/enum scope, alias resolution, shadowing and qualifier fixes |
| no-unnecessary-template-expression | Updated to fc051153 | 185 current cases; string constraints, type templates, comments, canonical literals and raw escaping fixes |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tsgolint 4ebf80fd2b166cba4890c6896220fec4a1462b29
tsgolint ada797a9a5f1684b39e40a966e77183c59f4e2d2
typescript-go 2bd066d87f5bafd315be9f40889d0a60b9e58e0b
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@
"Tsx": false,
"Files": {},
"Diagnostics": []
},
{
"Code": "\nexport function matches(x: 1 | true | undefined): boolean {\n return x === true;\n}\n ",
"Only": false,
"Skip": false,
"FileName": "",
"Options": {
"allowComparingNullableBooleansToFalse": true,
"allowComparingNullableBooleansToTrue": false
},
"TSConfig": "",
"Tsx": false,
"Files": {},
"Diagnostics": []
}
],
"Invalid": [
Expand Down
Loading
Loading