From cfaaf3842bf52ac2be8761f8376fb47ec497f195 Mon Sep 17 00:00:00 2001 From: Tom Theisel Date: Fri, 30 Sep 2022 14:44:17 +0100 Subject: [PATCH] refactor!: remove `BlockStyle` and `isBlockStyle` --- .changeset/six-walls-sneeze.md | 9 +++++++++ astro-portabletext/src/types.ts | 15 ++------------- astro-portabletext/src/utils.ts | 10 ---------- astro-portabletext/test/lib/utils.test.ts | 22 +--------------------- 4 files changed, 12 insertions(+), 44 deletions(-) create mode 100644 .changeset/six-walls-sneeze.md diff --git a/.changeset/six-walls-sneeze.md b/.changeset/six-walls-sneeze.md new file mode 100644 index 0000000..c9f5686 --- /dev/null +++ b/.changeset/six-walls-sneeze.md @@ -0,0 +1,9 @@ +--- +"astro-portabletext": minor +--- + +**BREAKING** + +- Removed deprecated `BlockStyle` type; use `Block` type instead +- Removed deprecated `isBlockStyle`; a utility _type guard_ function which is tied to `BlockStyle` +and has no purpose \ No newline at end of file diff --git a/astro-portabletext/src/types.ts b/astro-portabletext/src/types.ts index 2b4ce3d..4bd75e1 100644 --- a/astro-portabletext/src/types.ts +++ b/astro-portabletext/src/types.ts @@ -66,11 +66,11 @@ export interface PortableTextComponents { /** * How blocks should be rendered */ - block: ComponentOrRecord | ComponentOrRecord; + block: ComponentOrRecord; /** * Used when a `block` handler isn't found */ - unknownBlock: Component | Component; + unknownBlock: Component; /** * How lists should be rendered */ @@ -144,17 +144,6 @@ export interface Block extends PortableTextBlock { style: "normal" | PortableTextBlockStyle; } -/** - * @deprecated Use `Block` instead - * - * @example - * import type { BlockStyle, Props } from "astro-portabletext/types"; - * const props = Astro.props as Props; - */ -export interface BlockStyle extends Block { - style: "normal" | PortableTextBlockStyle; -} - /** * Alias to `ToolkitPortableTextList` * diff --git a/astro-portabletext/src/utils.ts b/astro-portabletext/src/utils.ts index 1766d25..5a483a7 100644 --- a/astro-portabletext/src/utils.ts +++ b/astro-portabletext/src/utils.ts @@ -1,12 +1,2 @@ -import type { TypedObject, BlockStyle } from "./types"; - export { toPlainText } from "@portabletext/toolkit"; export { mergeComponents } from "./internal"; - -/** - * @deprecated Has no purpose anymore - * - * Checks if (node) is of {@link BlockStyle} - */ -export const isBlockStyle = (node: TypedObject): node is BlockStyle => - typeof (node as BlockStyle).style === "string"; diff --git a/astro-portabletext/test/lib/utils.test.ts b/astro-portabletext/test/lib/utils.test.ts index 6d7830d..1892734 100644 --- a/astro-portabletext/test/lib/utils.test.ts +++ b/astro-portabletext/test/lib/utils.test.ts @@ -1,26 +1,6 @@ import { suite } from "uvu"; import * as assert from "uvu/assert"; -import { isBlockStyle, mergeComponents } from "../../src/utils"; - -// ---------------------------------------------------------------------------- -// Test `isBlockStyle` -// ---------------------------------------------------------------------------- - -const testIsBlockStyle = suite("isBlockStyle"); - -testIsBlockStyle("returns true for block style", () => { - const node = { _type: "block", style: "normal" }; - - assert.ok(isBlockStyle(node)); -}); - -testIsBlockStyle("returns false for non-block style", () => { - const node = { _type: "block" }; - - assert.not.ok(isBlockStyle(node)); -}); - -testIsBlockStyle.run(); +import { mergeComponents } from "../../src/utils"; // ---------------------------------------------------------------------------- // Test `mergeComponents`