mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(linter): fix fixer panic in typescript/consistent_indexed_object_style (#4165)
This commit is contained in:
parent
28eeee0f71
commit
f2b32731df
1 changed files with 7 additions and 2 deletions
|
|
@ -230,8 +230,8 @@ impl Rule for ConsistentIndexedObjectStyle {
|
|||
),
|
||||
|fixer| {
|
||||
let key = fixer.source_range(first.span);
|
||||
let params_span = Span::new(first.span.end + 2, tref.span.end - 1);
|
||||
let params = fixer.source_range(params_span);
|
||||
let params_span = Span::new(first.span.end + 1, tref.span.end - 1);
|
||||
let params = fixer.source_range(params_span).trim();
|
||||
let content = format!("{{ [key: {key}]: {params} }}");
|
||||
fixer.replace(tref.span, content)
|
||||
},
|
||||
|
|
@ -263,6 +263,11 @@ fn test() {
|
|||
"type Foo<T> = { [key: string]: T };",
|
||||
Some(serde_json::json!(["index-signature"])),
|
||||
),
|
||||
(
|
||||
"export function getCookies (headers: Headers): Record<string,Østring>",
|
||||
"export function getCookies (headers: Headers): { [key: string]: Østring }",
|
||||
Some(serde_json::json!(["index-signature"])),
|
||||
),
|
||||
];
|
||||
|
||||
let pass = vec![
|
||||
|
|
|
|||
Loading…
Reference in a new issue