mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
Fix TS 4.8 errors
This commit is contained in:
parent
4560a33187
commit
0add1a99b4
@ -1,6 +1,11 @@
|
||||
import type { API } from '@storybook/api';
|
||||
import { ADDON_ID } from './constants';
|
||||
|
||||
type State = {
|
||||
selected: string;
|
||||
isRotated: boolean;
|
||||
};
|
||||
|
||||
const getCurrentViewportIndex = (viewportsKeys: string[], current: string): number =>
|
||||
viewportsKeys.indexOf(current);
|
||||
|
||||
@ -24,7 +29,7 @@ export const registerShortcuts = async (api: API, setState: any, viewportsKeys:
|
||||
defaultShortcut: ['shift', 'V'],
|
||||
actionName: 'previous',
|
||||
action: () => {
|
||||
const { selected, isRotated } = api.getAddonState(ADDON_ID);
|
||||
const { selected, isRotated } = api.getAddonState<State>(ADDON_ID);
|
||||
setState({
|
||||
selected: getPreviousViewport(viewportsKeys, selected),
|
||||
isRotated,
|
||||
@ -37,7 +42,7 @@ export const registerShortcuts = async (api: API, setState: any, viewportsKeys:
|
||||
defaultShortcut: ['V'],
|
||||
actionName: 'next',
|
||||
action: () => {
|
||||
const { selected, isRotated } = api.getAddonState(ADDON_ID);
|
||||
const { selected, isRotated } = api.getAddonState<State>(ADDON_ID);
|
||||
setState({
|
||||
selected: getNextViewport(viewportsKeys, selected),
|
||||
isRotated,
|
||||
@ -50,7 +55,7 @@ export const registerShortcuts = async (api: API, setState: any, viewportsKeys:
|
||||
defaultShortcut: ['alt', 'V'],
|
||||
actionName: 'reset',
|
||||
action: () => {
|
||||
const { isRotated } = api.getAddonState(ADDON_ID);
|
||||
const { isRotated } = api.getAddonState<State>(ADDON_ID);
|
||||
setState({
|
||||
selected: 'reset',
|
||||
isRotated,
|
||||
|
@ -152,7 +152,7 @@ export const deepDiff = (value: any, update: any): any => {
|
||||
};
|
||||
|
||||
export const NO_TARGET_NAME = '';
|
||||
export function groupArgsByTarget<TArgs = Args>({
|
||||
export function groupArgsByTarget<TArgs extends Args = Args>({
|
||||
args,
|
||||
argTypes,
|
||||
}: StoryContext<AnyFramework, TArgs>) {
|
||||
@ -166,6 +166,8 @@ export function groupArgsByTarget<TArgs = Args>({
|
||||
return groupedArgs;
|
||||
}
|
||||
|
||||
export function noTargetArgs<TArgs = Args>(context: StoryContext<AnyFramework, TArgs>) {
|
||||
export function noTargetArgs<TArgs extends Args = Args>(
|
||||
context: StoryContext<AnyFramework, TArgs>
|
||||
) {
|
||||
return groupArgsByTarget(context)[NO_TARGET_NAME];
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ const defaultProjectAnnotations: ProjectAnnotations<ReactFramework> = {
|
||||
* @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
|
||||
* @param [exportsName] - in case your story does not contain a name and you want it to have a name.
|
||||
*/
|
||||
export function composeStory<TArgs = Args>(
|
||||
export function composeStory<TArgs extends Args = Args>(
|
||||
story: Store_ComposedStory<ReactFramework, TArgs>,
|
||||
componentAnnotations: Meta<TArgs | any>,
|
||||
projectAnnotations?: ProjectAnnotations<ReactFramework>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user