From 113cfc91b434c414f864946d7d8f1c15ed8c36ec Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Thu, 8 Dec 2022 16:50:26 +0100 Subject: [PATCH] Fix bug with meta not working well as generic parameter for StoryObj --- code/addons/links/package.json | 2 +- .../storyshots-puppeteer/package.json | 2 +- code/lib/codemod/package.json | 2 +- code/lib/core-server/package.json | 2 +- code/lib/csf-tools/package.json | 2 +- code/lib/manager-api/package.json | 2 +- code/lib/preview-api/package.json | 2 +- code/lib/source-loader/package.json | 2 +- code/lib/types/package.json | 2 +- code/package.json | 2 +- .../renderers/react/src/public-types.test.tsx | 28 ++++++++++++ code/ui/blocks/package.json | 2 +- code/ui/blocks/src/blocks/Canvas.stories.tsx | 10 ++--- code/ui/components/package.json | 2 +- code/yarn.lock | 44 +++++++++---------- 15 files changed, 67 insertions(+), 39 deletions(-) diff --git a/code/addons/links/package.json b/code/addons/links/package.json index 91d336dd9351..bb510375d053 100644 --- a/code/addons/links/package.json +++ b/code/addons/links/package.json @@ -78,7 +78,7 @@ "dependencies": { "@storybook/client-logger": "7.0.0-beta.0", "@storybook/core-events": "7.0.0-beta.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/manager-api": "7.0.0-beta.0", "@storybook/preview-api": "7.0.0-beta.0", "@storybook/router": "7.0.0-beta.0", diff --git a/code/addons/storyshots/storyshots-puppeteer/package.json b/code/addons/storyshots/storyshots-puppeteer/package.json index 889a22e6c14d..707f9ce66c5c 100644 --- a/code/addons/storyshots/storyshots-puppeteer/package.json +++ b/code/addons/storyshots/storyshots-puppeteer/package.json @@ -34,7 +34,7 @@ }, "dependencies": { "@axe-core/puppeteer": "^4.2.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/node-logger": "7.0.0-beta.0", "@storybook/types": "7.0.0-beta.0", "@types/jest-image-snapshot": "^5.1.0", diff --git a/code/lib/codemod/package.json b/code/lib/codemod/package.json index e67361cb21a6..0d294400d56e 100644 --- a/code/lib/codemod/package.json +++ b/code/lib/codemod/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@babel/types": "^7.20.2", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/csf-tools": "7.0.0-beta.0", "@storybook/node-logger": "7.0.0-beta.0", "@storybook/types": "7.0.0-beta.0", diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json index 34dc13fc4c13..e521b40c6bed 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -38,7 +38,7 @@ "@storybook/builder-manager": "7.0.0-beta.0", "@storybook/core-common": "7.0.0-beta.0", "@storybook/core-events": "7.0.0-beta.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/csf-tools": "7.0.0-beta.0", "@storybook/docs-mdx": "next", "@storybook/node-logger": "7.0.0-beta.0", diff --git a/code/lib/csf-tools/package.json b/code/lib/csf-tools/package.json index 1c602d6731f0..08aa93275902 100644 --- a/code/lib/csf-tools/package.json +++ b/code/lib/csf-tools/package.json @@ -43,7 +43,7 @@ }, "dependencies": { "@babel/types": "^7.20.2", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/types": "7.0.0-beta.0", "fs-extra": "^9.0.1", "ts-dedent": "^2.0.0" diff --git a/code/lib/manager-api/package.json b/code/lib/manager-api/package.json index d0d4d91d1b56..f81e1f57e1cb 100644 --- a/code/lib/manager-api/package.json +++ b/code/lib/manager-api/package.json @@ -44,7 +44,7 @@ "@storybook/channels": "7.0.0-beta.0", "@storybook/client-logger": "7.0.0-beta.0", "@storybook/core-events": "7.0.0-beta.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/router": "7.0.0-beta.0", "@storybook/theming": "7.0.0-beta.0", "@storybook/types": "7.0.0-beta.0", diff --git a/code/lib/preview-api/package.json b/code/lib/preview-api/package.json index ade912eff277..e1bc46af9d2c 100644 --- a/code/lib/preview-api/package.json +++ b/code/lib/preview-api/package.json @@ -71,7 +71,7 @@ "@storybook/channels": "7.0.0-beta.0", "@storybook/client-logger": "7.0.0-beta.0", "@storybook/core-events": "7.0.0-beta.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/types": "7.0.0-beta.0", "@types/qs": "^6.9.5", "dequal": "^2.0.2", diff --git a/code/lib/source-loader/package.json b/code/lib/source-loader/package.json index ccd16a466897..70b781c9ae4d 100644 --- a/code/lib/source-loader/package.json +++ b/code/lib/source-loader/package.json @@ -43,7 +43,7 @@ "prep": "../../../scripts/prepare/bundle.ts" }, "dependencies": { - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/types": "7.0.0-beta.0", "estraverse": "^5.2.0", "lodash": "^4.17.21", diff --git a/code/lib/types/package.json b/code/lib/types/package.json index 16b13496a5ac..2009e4ce1fff 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -48,7 +48,7 @@ "file-system-cache": "^2.0.0" }, "devDependencies": { - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@types/node": "^16.0.0", "typescript": "~4.9.3" }, diff --git a/code/package.json b/code/package.json index d36099cedc27..9c15a725327f 100644 --- a/code/package.json +++ b/code/package.json @@ -184,7 +184,7 @@ "@storybook/core-events": "workspace:*", "@storybook/core-server": "workspace:*", "@storybook/core-webpack": "workspace:*", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/csf-plugin": "workspace:*", "@storybook/csf-tools": "workspace:*", "@storybook/docs-tools": "workspace:*", diff --git a/code/renderers/react/src/public-types.test.tsx b/code/renderers/react/src/public-types.test.tsx index 68b68fd23b28..c955c6b59fb2 100644 --- a/code/renderers/react/src/public-types.test.tsx +++ b/code/renderers/react/src/public-types.test.tsx @@ -200,3 +200,31 @@ describe('Story args can be inferred', () => { expectTypeOf(Basic).toEqualTypeOf(); }); }); + +test('StoryObj is allowed when meta is upcasted to Meta', () => { + expectTypeOf>>().toEqualTypeOf< + ReactStory< + ButtonProps & { children?: ReactNode }, + Partial + > + >(); +}); + +test('StoryObj is allowed when meta is upcasted to Meta', () => { + expectTypeOf>>().toEqualTypeOf< + ReactStory< + ButtonProps & { children?: ReactNode }, + Partial + > + >(); +}); + +test('StoryObj is allowed when all arguments are optional', () => { + expectTypeOf>>().toEqualTypeOf< + ReactStory<{ label?: string; children?: ReactNode }, { label?: string; children?: ReactNode }> + >(); +}); + +test('Meta can be used without generic', () => { + expectTypeOf({ component: Button }).toMatchTypeOf(); +}); diff --git a/code/ui/blocks/package.json b/code/ui/blocks/package.json index 6b95b443cd69..88253094d720 100644 --- a/code/ui/blocks/package.json +++ b/code/ui/blocks/package.json @@ -47,7 +47,7 @@ "@storybook/client-logger": "7.0.0-beta.0", "@storybook/components": "7.0.0-beta.0", "@storybook/core-events": "7.0.0-beta.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/docs-tools": "7.0.0-beta.0", "@storybook/manager-api": "7.0.0-beta.0", "@storybook/preview-api": "7.0.0-beta.0", diff --git a/code/ui/blocks/src/blocks/Canvas.stories.tsx b/code/ui/blocks/src/blocks/Canvas.stories.tsx index 764ccd3225c0..e7eadab0c563 100644 --- a/code/ui/blocks/src/blocks/Canvas.stories.tsx +++ b/code/ui/blocks/src/blocks/Canvas.stories.tsx @@ -1,6 +1,6 @@ import React from 'react'; import type { Meta, StoryObj } from '@storybook/react'; -import { Canvas } from './Canvas'; +import { Canvas, SourceState } from './Canvas'; import { Story as StoryComponent } from './Story'; import * as BooleanStories from '../controls/Boolean.stories'; @@ -25,12 +25,12 @@ export const BasicStory: Story = {}; export const WithSourceOpen: Story = { args: { - withSource: 'open', + withSource: SourceState.OPEN, }, }; export const WithSourceClosed: Story = { args: { - withSource: 'closed', + withSource: SourceState.CLOSED, }, }; @@ -38,7 +38,7 @@ export const WithSourceClosed: Story = { export const WithMdxSource: Story = { name: 'With MDX Source', args: { - withSource: 'open', + withSource: SourceState.CLOSED, mdxSource: `const thisIsCustomSource = true; if (isSyntaxHighlighted) { console.log('syntax highlighting is working'); @@ -48,7 +48,7 @@ if (isSyntaxHighlighted) { export const WithoutSource: Story = { args: { - withSource: 'none', + withSource: SourceState.CLOSED, }, }; diff --git a/code/ui/components/package.json b/code/ui/components/package.json index 4f34be6b3104..49f1d41d2599 100644 --- a/code/ui/components/package.json +++ b/code/ui/components/package.json @@ -52,7 +52,7 @@ }, "dependencies": { "@storybook/client-logger": "7.0.0-beta.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.60.011a95e.0", "@storybook/theming": "7.0.0-beta.0", "@storybook/types": "7.0.0-beta.0", "memoizerific": "^1.11.3", diff --git a/code/yarn.lock b/code/yarn.lock index ca2670913f08..669484c034c6 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5385,7 +5385,7 @@ __metadata: dependencies: "@storybook/client-logger": 7.0.0-beta.0 "@storybook/core-events": 7.0.0-beta.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/manager-api": 7.0.0-beta.0 "@storybook/preview-api": 7.0.0-beta.0 "@storybook/router": 7.0.0-beta.0 @@ -5457,7 +5457,7 @@ __metadata: resolution: "@storybook/addon-storyshots-puppeteer@workspace:addons/storyshots/storyshots-puppeteer" dependencies: "@axe-core/puppeteer": ^4.2.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/node-logger": 7.0.0-beta.0 "@storybook/types": 7.0.0-beta.0 "@types/jest-image-snapshot": ^5.1.0 @@ -5819,7 +5819,7 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.0 "@storybook/components": 7.0.0-beta.0 "@storybook/core-events": 7.0.0-beta.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/docs-tools": 7.0.0-beta.0 "@storybook/manager-api": 7.0.0-beta.0 "@storybook/preview-api": 7.0.0-beta.0 @@ -6098,7 +6098,7 @@ __metadata: resolution: "@storybook/codemod@workspace:lib/codemod" dependencies: "@babel/types": ^7.20.2 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/csf-tools": 7.0.0-beta.0 "@storybook/node-logger": 7.0.0-beta.0 "@storybook/types": 7.0.0-beta.0 @@ -6121,7 +6121,7 @@ __metadata: dependencies: "@popperjs/core": ^2.6.0 "@storybook/client-logger": 7.0.0-beta.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/theming": 7.0.0-beta.0 "@storybook/types": 7.0.0-beta.0 "@types/overlayscrollbars": ^1.12.0 @@ -6219,7 +6219,7 @@ __metadata: "@storybook/builder-webpack5": 7.0.0-beta.0 "@storybook/core-common": 7.0.0-beta.0 "@storybook/core-events": 7.0.0-beta.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/csf-tools": 7.0.0-beta.0 "@storybook/docs-mdx": next "@storybook/node-logger": 7.0.0-beta.0 @@ -6306,7 +6306,7 @@ __metadata: "@babel/parser": ^7.20.3 "@babel/traverse": ^7.20.1 "@babel/types": ^7.20.2 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/types": 7.0.0-beta.0 "@types/fs-extra": ^9.0.6 fs-extra: ^9.0.1 @@ -6325,23 +6325,23 @@ __metadata: languageName: node linkType: hard -"@storybook/csf@npm:^0.0.1": - version: 0.0.1 - resolution: "@storybook/csf@npm:0.0.1" +"@storybook/csf@npm:0.0.2--canary.60.011a95e.0": + version: 0.0.2--canary.60.011a95e.0 + resolution: "@storybook/csf@npm:0.0.2--canary.60.011a95e.0" dependencies: + expect-type: ^0.14.2 lodash: ^4.17.15 - checksum: 7b0f75763415f9147692a460b44417ee56ea9639433716a1fd4d1df4c8b0221cbc71b8da0fbed4dcecb3ccd6c7ed64be39f5c255c713539a6088a1d6488aaa24 + type-fest: ^2.19.0 + checksum: ee63482c11dab2de13fcef1916fec235130d02446642da087907e04b9e8672169f0b11efa40bf3ca699d497a53882b4928349163b77ca2161546f16d6f987484 languageName: node linkType: hard -"@storybook/csf@npm:next": - version: 0.0.2-next.7 - resolution: "@storybook/csf@npm:0.0.2-next.7" +"@storybook/csf@npm:^0.0.1": + version: 0.0.1 + resolution: "@storybook/csf@npm:0.0.1" dependencies: - expect-type: ^0.14.2 lodash: ^4.17.15 - type-fest: ^2.19.0 - checksum: 3920626fdd6dc4875ba95ae46fa0776051f544a479029ee7d561b87602511010161750a42b0d5e1371ec336b47262e1098524c834805ca686d9bc2de5cae0e4e + checksum: 7b0f75763415f9147692a460b44417ee56ea9639433716a1fd4d1df4c8b0221cbc71b8da0fbed4dcecb3ccd6c7ed64be39f5c255c713539a6088a1d6488aaa24 languageName: node linkType: hard @@ -6567,7 +6567,7 @@ __metadata: "@storybook/channels": 7.0.0-beta.0 "@storybook/client-logger": 7.0.0-beta.0 "@storybook/core-events": 7.0.0-beta.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/router": 7.0.0-beta.0 "@storybook/theming": 7.0.0-beta.0 "@storybook/types": 7.0.0-beta.0 @@ -6920,7 +6920,7 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.0 "@storybook/core-common": 7.0.0-beta.0 "@storybook/core-events": 7.0.0-beta.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/types": 7.0.0-beta.0 "@types/qs": ^6.9.5 ansi-to-html: ^0.6.11 @@ -7127,7 +7127,7 @@ __metadata: "@storybook/core-events": "workspace:*" "@storybook/core-server": "workspace:*" "@storybook/core-webpack": "workspace:*" - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/csf-plugin": "workspace:*" "@storybook/csf-tools": "workspace:*" "@storybook/docs-tools": "workspace:*" @@ -7405,7 +7405,7 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/source-loader@workspace:lib/source-loader" dependencies: - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@storybook/types": 7.0.0-beta.0 estraverse: ^5.2.0 jest-specific-snapshot: ^7.0.0 @@ -7587,7 +7587,7 @@ __metadata: dependencies: "@babel/core": ^7.12.10 "@storybook/channels": 7.0.0-beta.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.60.011a95e.0 "@types/babel__core": ^7.0.0 "@types/express": ^4.7.0 "@types/node": ^16.0.0