Skip to content

Commit

Permalink
refactor!: remove BlockStyle and isBlockStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
theisel committed Sep 30, 2022
1 parent 6ef982b commit cfaaf38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 44 deletions.
9 changes: 9 additions & 0 deletions .changeset/six-walls-sneeze.md
Original file line number Diff line number Diff line change
@@ -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
15 changes: 2 additions & 13 deletions astro-portabletext/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export interface PortableTextComponents {
/**
* How blocks should be rendered
*/
block: ComponentOrRecord<BlockStyle> | ComponentOrRecord<Block>;
block: ComponentOrRecord<Block>;
/**
* Used when a `block` handler isn't found
*/
unknownBlock: Component<BlockStyle> | Component<Block>;
unknownBlock: Component<Block>;
/**
* How lists should be rendered
*/
Expand Down Expand Up @@ -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<BlockStyle>;
*/
export interface BlockStyle extends Block {
style: "normal" | PortableTextBlockStyle;
}

/**
* Alias to `ToolkitPortableTextList`
*
Expand Down
10 changes: 0 additions & 10 deletions astro-portabletext/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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";
22 changes: 1 addition & 21 deletions astro-portabletext/test/lib/utils.test.ts
Original file line number Diff line number Diff line change
@@ -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`
Expand Down

0 comments on commit cfaaf38

Please sign in to comment.