Skip to content

Commit

Permalink
add type interface for condition
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewrfoster committed May 1, 2024
1 parent fe01f69 commit f393b3e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion blocks/condition/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ interface EditProps {
setAttributes: (attributes: any) => void;
}

// Structure for the SelectControl options.
interface Conditions {
value: string;
label: string;
}

// Structure coming from Conditions API.
interface Condition {
slug: string;
name: string;
}

/**
* The wp-conditional-blocks/condition block edit function.
*
Expand All @@ -37,7 +44,7 @@ export default function Edit({
.then((response) => {
// @ts-ignore
if (Array.isArray(response.message) && response.message.length > 0) {
const nextConditions = response.message.map((condition) => ({
const nextConditions = response.message.map((condition: Condition) => ({

Check failure on line 47 in blocks/condition/edit.tsx

View workflow job for this annotation

GitHub Actions / node-tests / Install, build, and test

'response' is of type 'unknown'.
value: condition.slug ?? '',
label: condition.name ?? '',
}));
Expand Down

0 comments on commit f393b3e

Please sign in to comment.