From 698337798fe9d9f713e2b5f181c2bacba81b8ebf Mon Sep 17 00:00:00 2001 From: James Ross Date: Mon, 22 Apr 2024 19:22:18 +0100 Subject: [PATCH 1/2] fix: better handle readonly InputType options --- src/story.test.ts | 19 +++++++++++++++++++ src/story.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/story.test.ts b/src/story.test.ts index 8d730c2..ebe34d9 100644 --- a/src/story.test.ts +++ b/src/story.test.ts @@ -57,6 +57,25 @@ const strict: XMeta = { argTypes: { x: { type: { name: 'string' } } }, }; +const options = ['foo', 'bar'] as const; +const simpleWithReadonlyOptions: XMeta = { + title: 'simple', + component: Button, + tags: ['foo', 'bar'], + decorators: [(storyFn, context) => `withDecorator(${storyFn(context)})`], + parameters: { a: () => null, b: NaN, c: Symbol('symbol') }, + loaders: [() => Promise.resolve({ d: '3' })], + args: { x: '1' }, + argTypes: { + x: { + control: { + type: 'select', + }, + options: options, + } + }, +} + // NOTE Various story usages const Simple: XStory = () => 'Simple'; diff --git a/src/story.ts b/src/story.ts index 551f6a3..aa9c596 100644 --- a/src/story.ts +++ b/src/story.ts @@ -131,7 +131,7 @@ export interface InputType { /** * @see https://storybook.js.org/docs/api/arg-types#options */ - options?: any[]; + options?: readonly any[]; /** * @see https://storybook.js.org/docs/api/arg-types#table */ From 47092330a4e581e0876a676cafd1c498280fe7df Mon Sep 17 00:00:00 2001 From: James Ross Date: Thu, 25 Apr 2024 21:03:03 +0100 Subject: [PATCH 2/2] chore: resolve eslint issues --- src/story.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/story.test.ts b/src/story.test.ts index ebe34d9..38bbc59 100644 --- a/src/story.test.ts +++ b/src/story.test.ts @@ -71,10 +71,10 @@ const simpleWithReadonlyOptions: XMeta = { control: { type: 'select', }, - options: options, - } + options, + }, }, -} +}; // NOTE Various story usages const Simple: XStory = () => 'Simple';