Skip to content

Commit

Permalink
fixup! Alternative approach for operators
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed May 21, 2024
1 parent 65be846 commit 55353fe
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/dataviews/src/filter-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ const FilterText = ( {
Value: <span className="dataviews-filter-summary__filter-text-value" />,
};

if ( ! filterInView ) {
return sprintf(
/* translators: 1: Filter name e.g.: "Unknown status for Author". */
__( 'Unknown status for %1$s' ),
filter.name
);
}
switch ( filterInView?.operator ) {
case undefined:
break;

switch ( filterInView.operator ) {
case 'isAny':
return createInterpolateElement(
sprintf(
Expand Down Expand Up @@ -168,9 +163,15 @@ const FilterText = ( {
default:
// This checks that the above cases are exhaustive to cover all possible
// operators. A type error here means a case is not covered.
filterInView.operator satisfies never;
filterInView!.operator satisfies never;
throw new TypeError( 'Invalid filter operator' );
}

return sprintf(
/* translators: 1: Filter name e.g.: "Unknown status for Author". */
__( 'Unknown status for %1$s' ),
filter.name
);
};

function OperatorSelector( {
Expand Down

0 comments on commit 55353fe

Please sign in to comment.