mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +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,7 +371,9 @@ impl Rule for PreferFunctionType {
|
|||
union_type.types.iter().for_each(|ts_type| {
|
||||
if let TSType::TSTypeLiteral(literal) = ts_type {
|
||||
let body = &literal.members;
|
||||
check_member(&body[0], node, ctx);
|
||||
if body.len() == 1 {
|
||||
check_member(&body[0], node, ctx);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -450,6 +452,7 @@ fn test() {
|
|||
(): void;
|
||||
}
|
||||
",
|
||||
"let foo: number | {};",
|
||||
];
|
||||
|
||||
let fail = vec![
|
||||
|
|
|
|||
Loading…
Reference in a new issue