Skip to content

Commit

Permalink
Merge pull request #22261 from storybookjs/norbert/fix-21820-second-e…
Browse files Browse the repository at this point in the history
…dition

fix bad typings file caused by egoist/tsup#782
  • Loading branch information
ndelangen authored and shilman committed May 3, 2023
1 parent b18526f commit 6d5567c
Show file tree
Hide file tree
Showing 23 changed files with 91 additions and 53 deletions.
3 changes: 2 additions & 1 deletion code/addons/backgrounds/src/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Addon_DecoratorFunction } from '@storybook/types';
import { withBackground } from './decorators/withBackground';
import { withGrid } from './decorators/withGrid';
import { PARAM_KEY } from './constants';

export const decorators = [withGrid, withBackground];
export const decorators: Addon_DecoratorFunction[] = [withGrid, withBackground];
export const parameters = {
[PARAM_KEY]: {
grid: {
Expand Down
3 changes: 2 additions & 1 deletion code/addons/links/src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Addon_DecoratorFunction } from '@storybook/types';
import { withLinks } from './index';

export const decorators = [withLinks];
export const decorators: Addon_DecoratorFunction[] = [withLinks];
3 changes: 2 additions & 1 deletion code/addons/measure/src/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Addon_DecoratorFunction } from '@storybook/types';
import { withMeasure } from './withMeasure';
import { PARAM_KEY } from './constants';

export const decorators = [withMeasure];
export const decorators: Addon_DecoratorFunction[] = [withMeasure];

export const globals = {
[PARAM_KEY]: false,
Expand Down
3 changes: 2 additions & 1 deletion code/addons/outline/src/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Addon_DecoratorFunction } from '@storybook/types';
import { withOutline } from './withOutline';
import { PARAM_KEY } from './constants';

export const decorators = [withOutline];
export const decorators: Addon_DecoratorFunction[] = [withOutline];

export const globals = {
[PARAM_KEY]: false,
Expand Down
7 changes: 6 additions & 1 deletion code/frameworks/nextjs/src/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Addon_DecoratorFunction } from '@storybook/types';
import './config/preview';
import { RouterDecorator } from './routing/decorator';
import { StyledJsxDecorator } from './styledJsx/decorator';
Expand All @@ -13,7 +14,11 @@ function addNextHeadCount() {

addNextHeadCount();

export const decorators = [StyledJsxDecorator, RouterDecorator, HeadManagerDecorator];
export const decorators: Addon_DecoratorFunction<any>[] = [
StyledJsxDecorator,
RouterDecorator,
HeadManagerDecorator,
];

export const parameters = {
docs: {
Expand Down
5 changes: 2 additions & 3 deletions code/lib/builder-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { wrapManagerEntries } from './utils/managerEntries';
import type {
BuilderBuildResult,
BuilderFunction,
BuilderStartOptions,
BuilderStartResult,
Compilation,
ManagerBuilder,
Expand Down Expand Up @@ -282,7 +281,7 @@ export const bail: ManagerBuilder['bail'] = async () => {
}
};

export const start = async (options: BuilderStartOptions) => {
export const start: ManagerBuilder['start'] = async (options) => {
asyncIterator = starter(options);
let result;

Expand All @@ -294,7 +293,7 @@ export const start = async (options: BuilderStartOptions) => {
return result.value;
};

export const build = async (options: BuilderStartOptions) => {
export const build: ManagerBuilder['build'] = async (options) => {
asyncIterator = builder(options);
let result;

Expand Down
3 changes: 2 additions & 1 deletion code/renderers/html/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { parameters as docsParams } from './docs/config';
import type { Parameters } from './types';

export const parameters = { renderer: 'html' as const, ...docsParams };
export const parameters: Parameters = { renderer: 'html', ...docsParams };

export { decorators, argTypesEnhancers } from './docs/config';
export { renderToCanvas, render } from './render';
14 changes: 9 additions & 5 deletions code/renderers/html/src/docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import type { Addon_DecoratorFunction, ArgTypesEnhancer } from '@storybook/types';
import { SourceType, enhanceArgTypes } from '@storybook/docs-tools';

import { sourceDecorator } from './sourceDecorator';
import type { Parameters, StoryFnHtmlReturnType } from '../types';

export const decorators = [sourceDecorator];
export const decorators: Addon_DecoratorFunction<StoryFnHtmlReturnType>[] = [
sourceDecorator as Addon_DecoratorFunction<StoryFnHtmlReturnType>,
];

export const parameters = {
export const parameters: Partial<Parameters> = {
docs: {
story: { inline: true },
source: {
type: SourceType.DYNAMIC,
language: 'html',
code: undefined as unknown,
excludeDecorators: undefined as unknown,
code: undefined,
excludeDecorators: undefined,
},
},
};

export const argTypesEnhancers = [enhanceArgTypes];
export const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];
18 changes: 15 additions & 3 deletions code/renderers/html/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type {
StoryContext as DefaultStoryContext,
WebRenderer,
} from '@storybook/types';

import type { parameters } from './config';
import type { SourceType } from '@storybook/docs-tools';

export type { RenderContext } from '@storybook/types';

Expand All @@ -24,6 +23,19 @@ export interface HtmlRenderer extends WebRenderer {
storyResult: StoryFnHtmlReturnType;
}

export interface Parameters {
renderer: 'html';
docs?: {
story: { inline: boolean };
source: {
type: SourceType.DYNAMIC;
language: 'html';
code: any;
excludeDecorators: any;
};
};
}

export type StoryContext = DefaultStoryContext<HtmlRenderer> & {
parameters: DefaultStoryContext<HtmlRenderer>['parameters'] & typeof parameters;
parameters: DefaultStoryContext<HtmlRenderer>['parameters'] & Parameters;
};
2 changes: 1 addition & 1 deletion code/renderers/preact/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { parameters as docsParams } from './docs/config';

export { renderToCanvas, render } from './render';

export const parameters = { renderer: 'preact' as const, ...docsParams };
export const parameters: {} = { renderer: 'preact' as const, ...docsParams };
2 changes: 1 addition & 1 deletion code/renderers/react/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parameters as docsParams } from './docs/config';

export const parameters = { renderer: 'react', ...docsParams };
export const parameters: {} = { renderer: 'react', ...docsParams };

export { decorators, argTypesEnhancers } from './docs/config';

Expand Down
8 changes: 5 additions & 3 deletions code/renderers/react/src/docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import type { Addon_DecoratorFunction, ArgTypesEnhancer } from '@storybook/types';
import { extractComponentDescription, enhanceArgTypes } from '@storybook/docs-tools';

import { extractArgTypes } from './extractArgTypes';
import { jsxDecorator } from './jsxDecorator';
import type { StoryFnReactReturnType } from '../types';

export const parameters = {
export const parameters: {} = {
docs: {
story: { inline: true },
extractArgTypes,
extractComponentDescription,
},
};

export const decorators = [jsxDecorator];
export const decorators: Addon_DecoratorFunction<StoryFnReactReturnType>[] = [jsxDecorator];

export const argTypesEnhancers = [enhanceArgTypes];
export const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];
2 changes: 1 addition & 1 deletion code/renderers/svelte/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parameters as docsParams } from './docs/config';

export const parameters = { renderer: 'svelte' as const, ...docsParams };
export const parameters: {} = { renderer: 'svelte' as const, ...docsParams };
export { decorators, argTypesEnhancers } from './docs/config';

export { render, renderToCanvas } from './render';
Expand Down
7 changes: 4 additions & 3 deletions code/renderers/svelte/src/docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import type { Addon_DecoratorFunction, ArgTypesEnhancer } from '@storybook/types';
import { enhanceArgTypes } from '@storybook/docs-tools';
import { extractArgTypes } from './extractArgTypes';
import { extractComponentDescription } from './extractComponentDescription';
import { sourceDecorator } from './sourceDecorator';

export const parameters = {
export const parameters: {} = {
docs: {
story: { inline: true },
extractArgTypes,
extractComponentDescription,
},
};

export const decorators = [sourceDecorator];
export const decorators: Addon_DecoratorFunction<unknown>[] = [sourceDecorator];

export const argTypesEnhancers = [enhanceArgTypes];
export const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];
31 changes: 19 additions & 12 deletions code/renderers/svelte/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
/* eslint-disable prefer-destructuring */
import { start } from '@storybook/preview-api';
import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types';
import { decorateStory } from './decorators';

import type { SvelteRenderer } from './types';
import { render, renderToCanvas } from './render';

const {
configure: coreConfigure,
clientApi,
forceReRender,
} = start<SvelteRenderer>(renderToCanvas, {
const RENDERER = 'svelte';

interface ClientApi extends Addon_ClientStoryApi<SvelteRenderer['storyResult']> {
configure(loader: Addon_Loadable, module: NodeModule): void;
forceReRender(): void;
raw: () => any; // todo add type
}

const api = start<SvelteRenderer>(renderToCanvas, {
decorateStory,
render,
});

export const { raw } = clientApi;

const RENDERER = 'svelte';
export const storiesOf = (kind: string, m: any) =>
clientApi.storiesOf(kind, m).addParameters({ renderer: RENDERER });
export const configure = (...args: any[]) => coreConfigure(RENDERER, ...args);
export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
return (api.clientApi.storiesOf(kind, m) as ReturnType<ClientApi['storiesOf']>).addParameters({
renderer: RENDERER,
});
};

export { forceReRender };
export const configure: ClientApi['configure'] = (...args) => api.configure(RENDERER, ...args);
export const forceReRender: ClientApi['forceReRender'] = api.forceReRender;
export const raw: ClientApi['raw'] = api.clientApi.raw;
2 changes: 1 addition & 1 deletion code/renderers/vue/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parameters as docsParams } from './docs/config';

export const parameters = { renderer: 'vue' as const, ...docsParams };
export const parameters: {} = { renderer: 'vue' as const, ...docsParams };
export { decorators, argTypesEnhancers } from './docs/config';

export { render, renderToCanvas } from './render';
Expand Down
7 changes: 4 additions & 3 deletions code/renderers/vue/src/docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { Addon_DecoratorFunction, ArgTypesEnhancer } from '@storybook/types';
import { extractComponentDescription, enhanceArgTypes } from '@storybook/docs-tools';
import { extractArgTypes } from './extractArgTypes';
import { sourceDecorator } from './sourceDecorator';

export const parameters = {
export const parameters: {} = {
docs: {
story: { inline: true, iframeHeight: '120px' },
extractArgTypes,
extractComponentDescription,
},
};

export const decorators = [sourceDecorator];
export const decorators: Addon_DecoratorFunction<any>[] = [sourceDecorator];

export const argTypesEnhancers = [enhanceArgTypes];
export const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];
2 changes: 1 addition & 1 deletion code/renderers/vue3/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parameters as docsParams } from './docs/config';

export const parameters = { renderer: 'vue3' as const, ...docsParams };
export const parameters: {} = { renderer: 'vue3' as const, ...docsParams };
export { decorators, argTypesEnhancers } from './docs/config';

export { render, renderToCanvas } from './render';
Expand Down
7 changes: 4 additions & 3 deletions code/renderers/vue3/src/docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { Addon_DecoratorFunction, ArgTypesEnhancer } from '@storybook/types';
import { extractComponentDescription, enhanceArgTypes } from '@storybook/docs-tools';
import { extractArgTypes } from './extractArgTypes';
import { sourceDecorator } from './sourceDecorator';

export const parameters = {
export const parameters: {} = {
docs: {
story: { inline: true },
extractArgTypes,
extractComponentDescription,
},
};

export const decorators = [sourceDecorator];
export const decorators: Addon_DecoratorFunction<unknown>[] = [sourceDecorator];

export const argTypesEnhancers = [enhanceArgTypes];
export const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];
2 changes: 1 addition & 1 deletion code/renderers/web-components/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parameters as docsParams } from './docs/config';

export const parameters = { renderer: 'web-components' as const, ...docsParams };
export const parameters: {} = { renderer: 'web-components' as const, ...docsParams };
export { decorators, argTypesEnhancers } from './docs/config';
export { render, renderToCanvas } from './render';
7 changes: 4 additions & 3 deletions code/renderers/web-components/src/docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { Addon_DecoratorFunction, ArgTypesEnhancer } from '@storybook/types';
import { SourceType, enhanceArgTypes } from '@storybook/docs-tools';
import { extractArgTypes, extractComponentDescription } from './custom-elements';
import { sourceDecorator } from './sourceDecorator';

export const decorators = [sourceDecorator];
export const decorators: Addon_DecoratorFunction<unknown>[] = [sourceDecorator];

export const parameters = {
export const parameters: {} = {
docs: {
extractArgTypes,
extractComponentDescription,
Expand All @@ -16,4 +17,4 @@ export const parameters = {
},
};

export const argTypesEnhancers = [enhanceArgTypes];
export const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"trash": "^7.0.0",
"ts-dedent": "^2.0.0",
"ts-node": "^10.9.1",
"tsup": "^6.2.2",
"tsup": "^6.7.0",
"type-fest": "^3.4.0",
"typescript": "~4.9.3",
"util": "^0.12.4",
Expand Down
4 changes: 2 additions & 2 deletions scripts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2920,7 +2920,7 @@ __metadata:
ts-dedent: ^2.0.0
ts-loader: ^9.4.2
ts-node: ^10.9.1
tsup: ^6.2.2
tsup: ^6.7.0
type-fest: ^3.4.0
typescript: ~4.9.3
util: ^0.12.4
Expand Down Expand Up @@ -14561,7 +14561,7 @@ __metadata:
languageName: node
linkType: hard

"tsup@npm:^6.2.2":
"tsup@npm:^6.7.0":
version: 6.7.0
resolution: "tsup@npm:6.7.0"
dependencies:
Expand Down

0 comments on commit 6d5567c

Please sign in to comment.