storybookjs/storybook
View on GitHub[Bug]: Types are missing/unavailable for `options.storySort`
Open
#22,779 opened on May 25, 2023
bugcorehelp wantedsev:S3typescript
Description
Describe the bug
Even if I apply the Preview type (from @storybook/react), TypeScript doesn't know the types of the arguments to storySort:
preview.ts:33:17 - error TS7006: Parameter 'a' implicitly has an 'any' type.
33 storySort: (a, b) => {
~
preview.ts:33:20 - error TS7006: Parameter 'b' implicitly has an 'any' type.
33 storySort: (a, b) => {
~
The migration guide says that these arguments are of type StoryIndexEntry, but I can't find this type in the Storybook packages. I shouldn't even need to, because storySort should already have the correct types assigned to it.
To Reproduce
import type { Preview } from '@storybook/react';
export default <Preview>{
options: {
storySort: (a, b) => {
return a.title === b.title ? 0 : a.id.localeCompare(b.id, undefined, { numeric: true });
},
},
};
System
Environment Info:
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Binaries:
Node: 16.19.1 - C:\Program Files\Node.js\node.EXE
npm: 9.6.2 - C:\Program Files\Node.js\npm.CMD
Browsers:
Edge: Spartan (44.22621.1702.0), Chromium (113.0.1774.50)
npmPackages:
@storybook/addon-actions: 7.0.17 => 7.0.17
@storybook/addon-controls: 7.0.17 => 7.0.17
@storybook/addon-docs: 7.0.17 => 7.0.17
@storybook/addons: 7.0.17 => 7.0.17
@storybook/api: 7.0.17 => 7.0.17
@storybook/components: 7.0.17 => 7.0.17
@storybook/core-events: 7.0.17 => 7.0.17
@storybook/react: 7.0.17 => 7.0.17
@storybook/react-vite: 7.0.17 => 7.0.17
@storybook/theming: 7.0.17 => 7.0.17
Additional context
No response