Skip to content

Commit 5a6b9c4

Browse files
committed
Refactor
1 parent 8c8323b commit 5a6b9c4

File tree

2 files changed

+16
-35
lines changed

2 files changed

+16
-35
lines changed

libs/extractor/src/utils.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,7 @@ pub(super) fn wrap_direct_call<'a>(
197197
expr: &Expression<'a>,
198198
args: &[Expression<'a>],
199199
) -> Expression<'a> {
200-
builder.expression_call::<Option<oxc_allocator::Box<'_, oxc_ast::ast::TSTypeParameterInstantiation<'_>>>>(
201-
SPAN,
202-
expr.clone_in(builder.allocator),
203-
None,
204-
oxc_allocator::Vec::from_iter_in(
205-
args.iter().map(|e| e.clone_in(builder.allocator).into()),
206-
builder.allocator,
207-
),
208-
false,
209-
)
200+
builder.expression_call::<Option<oxc_allocator::Box<'_, oxc_ast::ast::TSTypeParameterInstantiation<'_>>>>(SPAN, expr.clone_in(builder.allocator), None, oxc_allocator::Vec::from_iter_in(args.iter().map(|e| e.clone_in(builder.allocator).into()), builder.allocator), false)
210201
}
211202
/// merge expressions to object expression
212203
pub(super) fn merge_object_expressions<'a>(

libs/sheet/src/theme.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -218,34 +218,24 @@ impl<'de> Deserialize<'de> for Typographies {
218218
match &value {
219219
// Traditional array format: [{ fontFamily: "Arial", ... }, null, { ... }]
220220
Value::Array(arr) => {
221-
// Check if this looks like a traditional typography array (array of objects/nulls)
222-
// vs a compact format that accidentally starts with an array
223-
let is_traditional = arr.iter().all(|v| v.is_object() || v.is_null());
224-
if is_traditional {
225-
let mut result = Vec::with_capacity(arr.len());
226-
for item in arr {
227-
match item {
228-
Value::Null => result.push(None),
229-
Value::Object(_) => {
230-
let typo: Typography = serde_json::from_value(item.clone())
231-
.map_err(D::Error::custom)?;
232-
result.push(Some(typo));
233-
}
234-
_ => {
235-
return Err(D::Error::custom(format!(
236-
"Typography array must contain objects or null, got: {:?}",
237-
item
238-
)));
239-
}
221+
let mut result = Vec::with_capacity(arr.len());
222+
for item in arr {
223+
match item {
224+
Value::Null => result.push(None),
225+
Value::Object(_) => {
226+
let typo: Typography =
227+
serde_json::from_value(item.clone()).map_err(D::Error::custom)?;
228+
result.push(Some(typo));
229+
}
230+
// Non-object/null values mean this is not a valid traditional array format
231+
_ => {
232+
return Err(D::Error::custom(
233+
"Typography value cannot start with an array. Use object format with property-level arrays instead.",
234+
));
240235
}
241236
}
242-
Ok(Self(result))
243-
} else {
244-
// Top-level array that's not a traditional format is an error
245-
Err(D::Error::custom(
246-
"Typography value cannot start with an array. Use object format with property-level arrays instead.",
247-
))
248237
}
238+
Ok(Self(result))
249239
}
250240
// Compact object format: { fontFamily: "Arial", fontSize: ["16px", null, "20px"], ... }
251241
Value::Object(obj) => {

0 commit comments

Comments
 (0)