diff --git a/code/addons/highlight/package.json b/code/addons/highlight/package.json index dad00fa7e4db..92a6e14cea96 100644 --- a/code/addons/highlight/package.json +++ b/code/addons/highlight/package.json @@ -58,15 +58,15 @@ "@types/webpack-env": "^1.16.0", "typescript": "~4.6.3" }, + "publishConfig": { + "access": "public" + }, "bundler": { "entries": [ "./src/index.ts", "./src/highlight.ts" ] }, - "publishConfig": { - "access": "public" - }, "gitHead": "438114fcf62a763f0e8c07e2c34890dd987ca431", "sbmodern": "dist/modern/index.js", "storybook": { diff --git a/code/lib/core-common/src/index.ts b/code/lib/core-common/src/index.ts index 5b95a7716571..034c4a9301c6 100644 --- a/code/lib/core-common/src/index.ts +++ b/code/lib/core-common/src/index.ts @@ -28,6 +28,7 @@ export * from './utils/normalize-stories'; export * from './utils/readTemplate'; export * from './utils/findDistEsm'; export * from './utils/symlinks'; +export * from './utils/satisfies'; export * from './types'; diff --git a/code/renderers/react/src/__test__/utils.ts b/code/lib/core-common/src/utils/satisfies.ts similarity index 100% rename from code/renderers/react/src/__test__/utils.ts rename to code/lib/core-common/src/utils/satisfies.ts diff --git a/code/package.json b/code/package.json index fc972e5f977e..fb1d8add2da6 100644 --- a/code/package.json +++ b/code/package.json @@ -111,6 +111,7 @@ ], "resolutions": { "@nrwl/cli": "14.6.1", + "@storybook/csf": "portal:/Users/kasperpeulen/code/storybook/csf", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/experimental-utils": "5.3.0", "@typescript-eslint/parser": "^5.15.0", @@ -336,7 +337,8 @@ "ts-jest": "^26.4.4", "ts-node": "^10.4.0", "tsup": "^6.2.2", - "typescript": "4.7.4", + "type-fest": "2.19.0", + "typescript": "~4.6.3", "util": "^0.12.4", "vite": "^3.1.7", "wait-on": "^5.2.1", @@ -346,6 +348,9 @@ "window-size": "^1.1.1", "zx": "^7.0.3" }, + "devDependencies": { + "expect-type": "^0.14.2" + }, "dependenciesMeta": { "@compodoc/compodoc": { "built": false diff --git a/code/renderers/react/package.json b/code/renderers/react/package.json index ae3c052755f8..68049a8d6747 100644 --- a/code/renderers/react/package.json +++ b/code/renderers/react/package.json @@ -76,7 +76,6 @@ "@babel/core": "^7.11.5", "@jest/globals": "^26.6.2", "@types/util-deprecate": "^1.0.0", - "expect-type": "^0.14.2", "jest-specific-snapshot": "^4.0.0", "require-from-string": "^2.0.2", "typescript": "~4.6.3" diff --git a/code/renderers/react/src/__test__/CSF3.test.tsx b/code/renderers/react/src/__test__/CSF3.test.tsx index 89bbb79aa3ea..94a73fee27bc 100644 --- a/code/renderers/react/src/__test__/CSF3.test.tsx +++ b/code/renderers/react/src/__test__/CSF3.test.tsx @@ -1,12 +1,11 @@ -import React, { KeyboardEventHandler, ReactNode } from 'react'; -import { expectTypeOf } from 'expect-type'; import { describe, test } from '@jest/globals'; +import { satisfies } from '@storybook/core-common'; import { StoryAnnotations } from '@storybook/csf'; +import { expectTypeOf } from 'expect-type'; +import React, { KeyboardEventHandler, ReactNode } from 'react'; import { SetOptional } from 'type-fest'; - -import { Meta, StoryObj } from '../public-types'; import { DecoratorFn } from '../public-api'; -import { satisfies } from './utils'; +import { Meta, StoryObj } from '../public-types'; import { ReactFramework } from '../types'; type ReactStory = StoryAnnotations; diff --git a/code/renderers/svelte/package.json b/code/renderers/svelte/package.json index ace782a2c08d..5a9a28bf74de 100644 --- a/code/renderers/svelte/package.json +++ b/code/renderers/svelte/package.json @@ -50,7 +50,7 @@ "*.d.ts" ], "scripts": { - "check": "../../../scripts/node_modules/.bin/tsc --noEmit", + "check": "svelte-check --tsconfig ./tsconfig.json", "prep": "../../../scripts/prepare/bundle.ts" }, "dependencies": { @@ -63,10 +63,12 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "sveltedoc-parser": "^4.2.1" + "sveltedoc-parser": "^4.2.1", + "type-fest": "2.19.0" }, "devDependencies": { "svelte": "^3.31.2", + "svelte-check": "^2.9.2", "typescript": "~4.6.3" }, "peerDependencies": { diff --git a/code/renderers/svelte/src/___test___/Button.svelte b/code/renderers/svelte/src/___test___/Button.svelte new file mode 100644 index 000000000000..b7fd6e8e325c --- /dev/null +++ b/code/renderers/svelte/src/___test___/Button.svelte @@ -0,0 +1,12 @@ + + + diff --git a/code/renderers/svelte/src/___test___/CSF3.test.ts b/code/renderers/svelte/src/___test___/CSF3.test.ts new file mode 100644 index 000000000000..84cc18481ea3 --- /dev/null +++ b/code/renderers/svelte/src/___test___/CSF3.test.ts @@ -0,0 +1,226 @@ +import { describe, test } from '@jest/globals'; +import { satisfies } from '@storybook/core-common'; +import { ComponentAnnotations, StoryAnnotations } from '@storybook/csf'; +import { expectTypeOf } from 'expect-type'; +import { ComponentProps, SvelteComponentTyped } from 'svelte'; + +import { DecoratorFn, Meta, StoryObj } from '../public-types'; +import { SvelteFramework } from '../types'; +import Button from './Button.svelte'; +import Decorator from './Decorator.svelte'; +import Decorator2 from './Decorator2.svelte'; + +type SvelteStory = StoryAnnotations< + SvelteFramework, + Args, + RequiredArgs +>; + +describe('Meta', () => { + test('Generic parameter of Meta can be a component', () => { + const meta: Meta