Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte: Remove deprecated SvelteComponentTyped in favor of SvelteComponent #26113

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/renderers/svelte/src/public-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { describe, it } from 'vitest';
import { satisfies } from '@storybook/core-common';
import type { ComponentAnnotations, StoryAnnotations } from '@storybook/types';
import { expectTypeOf } from 'expect-type';
import type { ComponentProps, SvelteComponentTyped } from 'svelte';
import type { ComponentProps, SvelteComponent } from 'svelte';
import Button from './__test__/Button.svelte';
import Decorator1 from './__test__/Decorator.svelte';
import Decorator2 from './__test__/Decorator2.svelte';

import type { Decorator, Meta, StoryObj } from './public-types';
import type { SvelteRenderer } from './types';

type SvelteStory<Component extends SvelteComponentTyped, Args, RequiredArgs> = StoryAnnotations<
type SvelteStory<Component extends SvelteComponent, Args, RequiredArgs> = StoryAnnotations<
SvelteRenderer<Component>,
Args,
RequiredArgs
Expand Down
8 changes: 4 additions & 4 deletions code/renderers/svelte/src/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
ProjectAnnotations,
} from '@storybook/types';

import type { ComponentType, ComponentProps, SvelteComponentTyped } from 'svelte';
import type { ComponentType, ComponentProps, SvelteComponent } from 'svelte';
import type { SetOptional, Simplify } from 'type-fest';
import type { SvelteRenderer } from './types';

Expand All @@ -23,15 +23,15 @@ export type { Args, ArgTypes, Parameters, StrictArgs } from '@storybook/types';
*
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
*/
export type Meta<CmpOrArgs = Args> = CmpOrArgs extends SvelteComponentTyped<infer Props>
export type Meta<CmpOrArgs = Args> = CmpOrArgs extends SvelteComponent<infer Props>
? ComponentAnnotations<SvelteRenderer<CmpOrArgs>, Props>
: ComponentAnnotations<SvelteRenderer, CmpOrArgs>;
/**
* Story function that represents a CSFv2 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
export type StoryFn<TCmpOrArgs = Args> = TCmpOrArgs extends SvelteComponentTyped<infer Props>
export type StoryFn<TCmpOrArgs = Args> = TCmpOrArgs extends SvelteComponent<infer Props>
? AnnotatedStoryFn<SvelteRenderer, Props>
: AnnotatedStoryFn<SvelteRenderer, TCmpOrArgs>;

Expand All @@ -54,7 +54,7 @@ export type StoryObj<MetaOrCmpOrArgs = Args> = MetaOrCmpOrArgs extends {
SetOptional<TArgs, Extract<keyof TArgs, keyof DefaultArgs>>
>
: never
: MetaOrCmpOrArgs extends SvelteComponentTyped
: MetaOrCmpOrArgs extends SvelteComponent
? StoryAnnotations<SvelteRenderer<MetaOrCmpOrArgs>, ComponentProps<MetaOrCmpOrArgs>>
: StoryAnnotations<SvelteRenderer, MetaOrCmpOrArgs>;

Expand Down
12 changes: 6 additions & 6 deletions code/renderers/svelte/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StoryContext as StoryContextBase, WebRenderer } from '@storybook/types';
import type { ComponentConstructorOptions, ComponentEvents, SvelteComponentTyped } from 'svelte';
import type { ComponentConstructorOptions, ComponentEvents, SvelteComponent } from 'svelte';

export type StoryContext = StoryContextBase<SvelteRenderer>;

Expand All @@ -26,13 +26,13 @@ type ComponentType<
Props extends Record<string, any> = any,
Events extends Record<string, any> = any,
> = new (options: ComponentConstructorOptions<Props>) => {
[P in keyof SvelteComponentTyped<Props> as P extends `$$${string}`
? never
: P]: SvelteComponentTyped<Props, Events>[P];
[P in keyof SvelteComponent<Props> as P extends `$$${string}` ? never : P]: SvelteComponent<
Props,
Events
>[P];
};

export interface SvelteRenderer<C extends SvelteComponentTyped = SvelteComponentTyped>
extends WebRenderer {
export interface SvelteRenderer<C extends SvelteComponent = SvelteComponent> extends WebRenderer {
component: ComponentType<this['T'] extends Record<string, any> ? this['T'] : any>;
storyResult: this['T'] extends Record<string, any>
? SvelteStoryResult<this['T'], ComponentEvents<C>>
Expand Down
Loading