From 1d520ad523ec6d102627d5db9d7a2da6b488257b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Hrub=C3=BD?= Date: Tue, 19 Dec 2023 12:25:26 +0100 Subject: [PATCH 1/2] CSF-tools: Allow type checking in storySort --- code/lib/csf-tools/src/getStorySortParameter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/lib/csf-tools/src/getStorySortParameter.ts b/code/lib/csf-tools/src/getStorySortParameter.ts index 426017c5f410..70d323d4edd6 100644 --- a/code/lib/csf-tools/src/getStorySortParameter.ts +++ b/code/lib/csf-tools/src/getStorySortParameter.ts @@ -19,7 +19,9 @@ const getValue = (obj: t.ObjectExpression, key: string) => { return value; }; -const parseValue = (expr: t.Expression): any => { +const parseValue = (value: t.Expression): any => { + const expr = stripTSModifiers(value); + if (t.isArrayExpression(expr)) { return (expr.elements as t.Expression[]).map((o) => { return parseValue(o); From b1c571d98d7d3093f6ec65afb5f5556b20520d33 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Tue, 9 Jan 2024 00:25:52 +0800 Subject: [PATCH 2/2] Add test --- .../src/getStorySortParameter.test.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/code/lib/csf-tools/src/getStorySortParameter.test.ts b/code/lib/csf-tools/src/getStorySortParameter.test.ts index bd34207de7c0..b2672bb0198c 100644 --- a/code/lib/csf-tools/src/getStorySortParameter.test.ts +++ b/code/lib/csf-tools/src/getStorySortParameter.test.ts @@ -450,6 +450,31 @@ export default { ] `); }); + + it('storysort satisfies inline', () => { + expect( + getStorySortParameter(dedent` + enum ComponentGroups { + General = 'General' + } + export default { + parameters: { + options: { + storySort: { + order: ['General'] satisfies ComponentGroups[] + } + } + } + }; + `) + ).toMatchInlineSnapshot(` + { + "order": [ + "General", + ], + } + `); + }); }); describe('unsupported', () => { it('bad default export', () => {