From a3fa103fb76328aff354983f0a37e29c4e997cb4 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 13 Aug 2024 20:55:49 +0200 Subject: [PATCH] feat: export types also from `@nuxtjs/storybook` (#749) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### ๐Ÿ”— Linked issue ### ๐Ÿ“š Description Export types from `@storybook/vue3` also at `@nuxtjs/storybook`. --- .vscode/settings.json | 2 +- .../content/1.getting-started/3.typescript.md | 46 +++++++++++++++++++ package.json | 2 +- packages/nuxt-module/package.json | 4 +- packages/nuxt-module/src/module.ts | 2 + .../storybook-addon/.storybook/tsconfig.json | 29 ------------ packages/storybook-addon/src/index.ts | 1 - packages/storybook-addon/src/types.d.ts | 10 ---- packages/storybook-addon/tsconfig.json | 4 +- pnpm-lock.yaml | 12 ++--- 10 files changed, 60 insertions(+), 52 deletions(-) create mode 100644 docs/content/1.getting-started/3.typescript.md delete mode 100644 packages/storybook-addon/.storybook/tsconfig.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 345516fe..6835316f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "cSpell.words": ["composables", "dedupe", "nuxt", "ofetch", "Pinia"] + "cSpell.words": ["composables", "dedupe", "nuxt", "nuxtjs", "ofetch", "Pinia"] } diff --git a/docs/content/1.getting-started/3.typescript.md b/docs/content/1.getting-started/3.typescript.md new file mode 100644 index 00000000..e43f311d --- /dev/null +++ b/docs/content/1.getting-started/3.typescript.md @@ -0,0 +1,46 @@ +--- +title: 'TypeScript' +description: 'Guide on how to use TypeScript with the Nuxt module' +--- + +To use the Nuxt module with TypeScript, ensure that imports typically from `@storybook/*` are now replaced by imports from `@nuxtjs/storybook` (or `@storybook-vue/nuxt` if the Nuxt module is not used). This is needed since the Storybook packages are dependencies of the Nuxt module, and are not directly installed in the project. + +The following example demonstrates how to use types when configuring Storybook and for writing stories. + +::code-group + +```typescript [.storybook/main.ts] +import { StorybookConfig } from '@nuxtjs/storybook' // not from '@storybook/core-common' + +export default { + stories: ['../components/**/*.stories.ts'], + addons: ['@storybook/addon-links', '@storybook/addon-essentials'], + framework: '@storybook/vue3', +} as StorybookConfig +``` + +```typescript [components/Button.stories.ts] +import { Meta, Story } from '@nuxtjs/storybook' // not from '@storybook/vue' +import Button from './Button.vue' + +export default { + title: 'Example/Button', + component: Button, +} as Meta + +const Template: Story = (args) => ({ + components: { Button }, + setup() { + return { args } + }, + template: '