From 677861bcd5f6632feb974c03345a099091b6f2eb Mon Sep 17 00:00:00 2001 From: Mikey Binns Date: Sat, 6 Apr 2024 01:36:32 +0100 Subject: [PATCH] add ShortcodeType to ease maintaining --- packages/shortcode/src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/shortcode/src/index.ts b/packages/shortcode/src/index.ts index 8a43c32140776e..190bf8598245b4 100644 --- a/packages/shortcode/src/index.ts +++ b/packages/shortcode/src/index.ts @@ -22,6 +22,8 @@ type WPShortcodeAttrs = { numeric: string[]; }; +type ShortcodeType = 'single' | 'self-closing' | 'closed'; + /** * Shortcode object. * @@ -49,7 +51,7 @@ type WPShortcodeOptions = { /** * Shortcode type. */ - type: 'single' | 'self-closing' | 'closed'; + type: ShortcodeType; }; /** @@ -279,7 +281,7 @@ export const attrs = memize( ( text: string ): WPShortcodeAttrs => { * @return {WPShortcode} Shortcode instance. */ export function fromMatch( match: RegExpExecArray ): WPShortcode { - let type: 'single' | 'self-closing' | 'closed'; + let type: ShortcodeType; if ( match[ 4 ] ) { type = 'self-closing'; @@ -325,7 +327,7 @@ function isWPShortcodeAttrsObject( class shortcode { tag?: string; attrs: WPShortcodeAttrs; - type?: 'single' | 'self-closing' | 'closed'; + type?: ShortcodeType; content?: string; constructor( options: WPShortcodeOptions ) {