Skip to content

Commit

Permalink
fix: better handle readonly InputType options
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherry committed Apr 22, 2024
1 parent 16942d6 commit 6983377
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/story.test.ts
Expand Up @@ -57,6 +57,25 @@ const strict: XMeta<ButtonArgs> = {
argTypes: { x: { type: { name: 'string' } } },
};

const options = ['foo', 'bar'] as const;
const simpleWithReadonlyOptions: XMeta<ButtonArgs> = {
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';

Expand Down
2 changes: 1 addition & 1 deletion src/story.ts
Expand Up @@ -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
*/
Expand Down

1 comment on commit 6983377

@tylerlaws0n
Copy link

@tylerlaws0n tylerlaws0n commented on 6983377 Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cherry Would you mind cutting a release for this change? I use readonly arrays for options frequently in my project so I'll need this change for completing my storybook v8 upgrade. Thanks! :)

Update: Please disregard this comment - I noticed this was tagged in 0.1.5 so double checked what I have and it seems npm mixed up the install somehow. I should be able to fix my issues by just reinstalling, apologies for any confusion caused here

Update 2: I see you made the MR to get this change in here: storybookjs/storybook#26958. Thanks for that!

Please sign in to comment.