From a1090c6abde3bc5f293b0af048de6cb9ef8b3ddf Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Tue, 26 Sep 2023 18:56:19 -0700 Subject: [PATCH] use Typescript to check cases are exhaustive --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 42dc3ed..91f55df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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) { @@ -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") { @@ -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) { @@ -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 { @@ -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) { @@ -276,6 +281,7 @@ function positionAndAlign( top = Math.round(anchorRect.bottom - elRect.height); break; default: + vAlign satisfies never; throw new Error("Should not happen"); } }