mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter): avoid crash if no members in TSTypeLiteral in typescript/prefer-function-type (#2604)
This commit is contained in:
parent
f6709e4737
commit
951297ee59
1 changed files with 4 additions and 1 deletions
|
|
@ -371,8 +371,10 @@ impl Rule for PreferFunctionType {
|
||||||
union_type.types.iter().for_each(|ts_type| {
|
union_type.types.iter().for_each(|ts_type| {
|
||||||
if let TSType::TSTypeLiteral(literal) = ts_type {
|
if let TSType::TSTypeLiteral(literal) = ts_type {
|
||||||
let body = &literal.members;
|
let body = &literal.members;
|
||||||
|
if body.len() == 1 {
|
||||||
check_member(&body[0], node, ctx);
|
check_member(&body[0], node, ctx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,6 +452,7 @@ fn test() {
|
||||||
(): void;
|
(): void;
|
||||||
}
|
}
|
||||||
",
|
",
|
||||||
|
"let foo: number | {};",
|
||||||
];
|
];
|
||||||
|
|
||||||
let fail = vec![
|
let fail = vec![
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue