Skip to content

Commit

Permalink
use Typescript to check cases are exhaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
Macil committed Sep 27, 2023
1 parent 41cc714 commit a1090c6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function positionAndAlign(
left = Math.ceil(anchorRect.right - elRect.width);
break;
default:
hAlign satisfies never;
throw new Error("Should not happen");
}
switch (vAlign) {
Expand All @@ -220,6 +221,7 @@ function positionAndAlign(
top = Math.ceil(anchorRect.bottom - elRect.height);
break;
default:
vAlign satisfies never;
throw new Error("Should not happen");
}
} else if (position === "top" || position === "bottom") {
Expand All @@ -233,6 +235,7 @@ function positionAndAlign(
top = Math.ceil(anchorRect.bottom + buffers.all + buffers.top);
break;
default:
position satisfies never;
throw new Error("Should not happen");
}
switch (hAlign) {
Expand All @@ -248,6 +251,7 @@ function positionAndAlign(
left = Math.round(anchorRect.right - elRect.width);
break;
default:
hAlign satisfies never;
throw new Error("Should not happen");
}
} else {
Expand All @@ -261,6 +265,7 @@ function positionAndAlign(
left = Math.ceil(anchorRect.right + buffers.all + buffers.left);
break;
default:
position satisfies never;
throw new Error("Should not happen");
}
switch (vAlign) {
Expand All @@ -276,6 +281,7 @@ function positionAndAlign(
top = Math.round(anchorRect.bottom - elRect.height);
break;
default:
vAlign satisfies never;
throw new Error("Should not happen");
}
}
Expand Down

0 comments on commit a1090c6

Please sign in to comment.