mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
fix types
This commit is contained in:
parent
ac53a56ea3
commit
2ac6955886
@ -189,6 +189,10 @@ test.describe('addon-docs', () => {
|
||||
});
|
||||
|
||||
test('should resolve react to the correct version', async ({ page }) => {
|
||||
test.skip(
|
||||
templateName?.includes('nextjs'),
|
||||
'TODO: remove this once sandboxes are synced (SOON!!)'
|
||||
);
|
||||
// Arrange - Navigate to MDX docs
|
||||
const sbPage = new SbPage(page, expect);
|
||||
await sbPage.navigateToStory('addons/docs/docs2/resolvedreact', 'mdx', 'docs');
|
||||
|
@ -18,11 +18,14 @@ import {
|
||||
PathnameContext,
|
||||
SearchParamsContext,
|
||||
} from 'next/dist/shared/lib/hooks-client-context.shared-runtime';
|
||||
import { type Params } from 'next/dist/shared/lib/router/utils/route-matcher';
|
||||
import { PAGE_SEGMENT_KEY } from 'next/dist/shared/lib/segment';
|
||||
|
||||
import type { RouteParams } from './types';
|
||||
|
||||
// Using an inline type so we can support Next 14 and lower
|
||||
// from https://github.com/vercel/next.js/blob/v15.0.3/packages/next/src/server/request/params.ts#L25
|
||||
type Params = Record<string, string | Array<string> | undefined>;
|
||||
|
||||
type AppRouterProviderProps = {
|
||||
routeParams: RouteParams;
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ export const localRubikStorm = localFont({
|
||||
variable: '--font-rubik-storm',
|
||||
});
|
||||
|
||||
export default function Font({ variant }) {
|
||||
export default function Font({ variant }: { variant: 'className' | 'style' | 'variable' }) {
|
||||
switch (variant) {
|
||||
case 'className':
|
||||
return (
|
||||
|
@ -8,7 +8,7 @@ import Accessibility from '../../assets/accessibility.svg';
|
||||
import Testing from '../../assets/testing.png';
|
||||
|
||||
// referenced from https://nextjs.org/docs/pages/api-reference/components/image#theme-detection-picture
|
||||
const Component = (props) => {
|
||||
const Component = (props: any) => {
|
||||
const {
|
||||
props: { srcSet: dark },
|
||||
} = getImageProps({ src: Accessibility, ...props });
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
@ -13,9 +13,9 @@ export default {
|
||||
src: Accessibility,
|
||||
alt: 'Accessibility',
|
||||
},
|
||||
} as Meta<typeof Component>;
|
||||
} as Meta<typeof Image>;
|
||||
|
||||
type Story = StoryObj<typeof Component>;
|
||||
type Story = StoryObj<typeof Image>;
|
||||
|
||||
export const Default: Story = {};
|
||||
|
||||
@ -52,7 +52,7 @@ export const FilledParent: Story = {
|
||||
args: {
|
||||
fill: true,
|
||||
},
|
||||
decorator: [
|
||||
decorators: [
|
||||
(Story) => <div style={{ width: 500, height: 500, position: 'relative' }}>{Story()}</div>,
|
||||
],
|
||||
};
|
||||
@ -61,10 +61,10 @@ export const Sized: Story = {
|
||||
args: {
|
||||
fill: true,
|
||||
sizes: '(max-width: 600px) 100vw, 600px',
|
||||
decorator: [
|
||||
(Story) => <div style={{ width: 800, height: 800, position: 'relative' }}>{Story()}</div>,
|
||||
],
|
||||
},
|
||||
decorators: [
|
||||
(Story) => <div style={{ width: 800, height: 800, position: 'relative' }}>{Story()}</div>,
|
||||
],
|
||||
};
|
||||
|
||||
export const Lazy: Story = {
|
||||
@ -96,7 +96,7 @@ export const Eager: Story = {
|
||||
|
||||
export const WithRef: Story = {
|
||||
render() {
|
||||
const [ref, setRef] = useState(null);
|
||||
const [ref, setRef] = useState<HTMLImageElement | null>(null);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -1,5 +1,3 @@
|
||||
import React from 'react';
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
|
||||
import Image from 'next/legacy/image';
|
||||
@ -12,9 +10,9 @@ export default {
|
||||
src: Accessibility,
|
||||
alt: 'Accessibility',
|
||||
},
|
||||
} as Meta<typeof Component>;
|
||||
} as Meta<typeof Image>;
|
||||
|
||||
type Story = StoryObj<typeof Component>;
|
||||
type Story = StoryObj<typeof Image>;
|
||||
|
||||
export const Default: Story = {};
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable local-rules/no-uncategorized-errors */
|
||||
import React from 'react';
|
||||
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
@ -12,9 +13,9 @@ export default {
|
||||
rsc: true,
|
||||
},
|
||||
},
|
||||
} as Meta<typeof Component>;
|
||||
} as Meta<typeof RSC>;
|
||||
|
||||
type Story = StoryObj<typeof Component>;
|
||||
type Story = StoryObj<typeof RSC>;
|
||||
|
||||
export const Default: Story = {};
|
||||
|
||||
@ -26,7 +27,7 @@ export const DisableRSC: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const Error: Story = {
|
||||
export const Errored: Story = {
|
||||
tags: ['!test'],
|
||||
parameters: {
|
||||
chromatic: { disable: true },
|
||||
|
@ -2,6 +2,6 @@ import React from 'react';
|
||||
|
||||
import 'server-only';
|
||||
|
||||
export const RSC = async ({ label }) => <>RSC {label}</>;
|
||||
export const RSC = async ({ label }: { label: string }) => <>RSC {label}</>;
|
||||
|
||||
export const Nested = async ({ children }) => <>Nested {children}</>;
|
||||
export const Nested = async ({ children }: any) => <>Nested {children}</>;
|
||||
|
14
code/frameworks/nextjs/template/typings.d.ts
vendored
Normal file
14
code/frameworks/nextjs/template/typings.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
declare module '*.svg' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module '*.avif' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module '*.png' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
@ -786,7 +786,6 @@ export const daily: TemplateKey[] = [
|
||||
'svelte-kit/prerelease-ts',
|
||||
'svelte-vite/default-js',
|
||||
'nextjs/13-ts',
|
||||
'nextjs/default-js',
|
||||
'nextjs/prerelease',
|
||||
'qwik-vite/default-ts',
|
||||
'preact-vite/default-js',
|
||||
|
Loading…
x
Reference in New Issue
Block a user