import { StrictArgs, DecoratorFunction, StoryContext as StoryContext$1, RenderContext as RenderContext$1, Args, ComponentAnnotations, AnnotatedStoryFn, ArgsStoryFn, ArgsFromMeta, StoryAnnotations, LoaderFunction, ProjectAnnotations, LegacyStoryFn } from 'storybook/internal/types'; import { Component, ComponentProps } from 'solid-js'; import { S as SolidRenderer } from './types-vFmObJUf.js'; /** Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153). @example ``` import type {UnionToIntersection} from 'type-fest'; type Union = {the(): void} | {great(arg: string): void} | {escape: boolean}; type Intersection = UnionToIntersection; //=> {the(): void} & {great(arg: string): void} & {escape: boolean} ``` @category Type */ type UnionToIntersection = ( // `extends unknown` is always going to be the case and is used to convert the // `Union` into a [distributive conditional // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). Union extends unknown // The union type is used as the only argument to a function since the union // of function arguments is an intersection. ? (distributedUnion: Union) => void // This won't happen. : never // Infer the `Intersection` type since TypeScript represents the positional // arguments of unions of functions as an intersection of the union. ) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection` is always assignable to `A | B` ? Intersection & Union : never; /** Create a union of all keys from a given type, even those exclusive to specific union members. Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member. @link https://stackoverflow.com/a/49402091 @example ``` import type {KeysOfUnion} from 'type-fest'; type A = { common: string; a: number; }; type B = { common: string; b: string; }; type C = { common: string; c: boolean; }; type Union = A | B | C; type CommonKeys = keyof Union; //=> 'common' type AllKeys = KeysOfUnion; //=> 'common' | 'a' | 'b' | 'c' ``` @category Object */ type KeysOfUnion = // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008 keyof UnionToIntersection : never>; /** Returns a boolean for whether the given type is `any`. @link https://stackoverflow.com/a/49928360/1490091 Useful in type utilities, such as disallowing `any`s to be passed to a function. @example ``` import type {IsAny} from 'type-fest'; const typedObject = {a: 1, b: 2} as const; const anyObject: any = {a: 1, b: 2}; function get extends true ? {} : Record), K extends keyof O = keyof O>(object: O, key: K) { return object[key]; } const typedA = get(typedObject, 'a'); //=> 1 const anyA = get(anyObject, 'a'); //=> any ``` @category Type Guard @category Utilities */ type IsAny = 0 extends 1 & NoInfer ? true : false; /** Returns a boolean for whether the given key is an optional key of type. This is useful when writing utility types or schema validators that need to differentiate `optional` keys. @example ``` import type {IsOptionalKeyOf} from 'type-fest'; type User = { name: string; surname: string; luckyNumber?: number; }; type Admin = { name: string; surname?: string; }; type T1 = IsOptionalKeyOf; //=> true type T2 = IsOptionalKeyOf; //=> false type T3 = IsOptionalKeyOf; //=> boolean type T4 = IsOptionalKeyOf; //=> false type T5 = IsOptionalKeyOf; //=> boolean ``` @category Type Guard @category Utilities */ type IsOptionalKeyOf = IsAny extends true ? never : Key extends keyof Type ? Type extends Record ? false : true : false; /** Extract all optional keys from the given type. This is useful when you want to create a new type that contains different type values for the optional keys only. @example ``` import type {OptionalKeysOf, Except} from 'type-fest'; type User = { name: string; surname: string; luckyNumber?: number; }; const REMOVE_FIELD = Symbol('remove field symbol'); type UpdateOperation = Except, OptionalKeysOf> & { [Key in OptionalKeysOf]?: Entity[Key] | typeof REMOVE_FIELD; }; const update1: UpdateOperation = { name: 'Alice', }; const update2: UpdateOperation = { name: 'Bob', luckyNumber: REMOVE_FIELD, }; ``` @category Utilities */ type OptionalKeysOf = Type extends unknown // For distributing `Type` ? (keyof {[Key in keyof Type as IsOptionalKeyOf extends false ? never : Key ]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf` is always assignable to `keyof Type` : never; // Should never happen /** Extract all required keys from the given type. This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc... @example ``` import type {RequiredKeysOf} from 'type-fest'; declare function createValidation< Entity extends object, Key extends RequiredKeysOf = RequiredKeysOf, >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean; type User = { name: string; surname: string; luckyNumber?: number; }; const validator1 = createValidation('name', value => value.length < 25); const validator2 = createValidation('surname', value => value.length < 25); // @ts-expect-error const validator3 = createValidation('luckyNumber', value => value > 0); // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'. ``` @category Utilities */ type RequiredKeysOf = Type extends unknown // For distributing `Type` ? Exclude> : never; // Should never happen /** Returns a boolean for whether the given type is `never`. @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919 @link https://stackoverflow.com/a/53984913/10292952 @link https://www.zhenghao.io/posts/ts-never Useful in type utilities, such as checking if something does not occur. @example ``` import type {IsNever, And} from 'type-fest'; type A = IsNever; //=> true type B = IsNever; //=> false type C = IsNever; //=> false type D = IsNever; //=> false type E = IsNever; //=> false type F = IsNever; //=> false ``` @example ``` import type {IsNever} from 'type-fest'; type IsTrue = T extends true ? true : false; // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`. type A = IsTrue; //=> never // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional. type IsTrueFixed = IsNever extends true ? false : T extends true ? true : false; type B = IsTrueFixed; //=> false ``` @category Type Guard @category Utilities */ type IsNever = [T] extends [never] ? true : false; /** An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`. Use-cases: - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If, 'is any', 'not any'>`. Note: - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If` will return `'Y' | 'N'`. - Returns the else branch if the given type is `never`. For example, `If` will return `'N'`. @example ``` import type {If} from 'type-fest'; type A = If; //=> 'yes' type B = If; //=> 'no' type C = If; //=> 'yes' | 'no' type D = If; //=> 'yes' | 'no' type E = If; //=> 'no' ``` @example ``` import type {If, IsAny, IsNever} from 'type-fest'; type A = If, 'is any', 'not any'>; //=> 'not any' type B = If, 'is never', 'not never'>; //=> 'is never' ``` @example ``` import type {If, IsEqual} from 'type-fest'; type IfEqual = If, IfBranch, ElseBranch>; type A = IfEqual; //=> 'equal' type B = IfEqual; //=> 'not equal' ``` Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example: @example ``` import type {If, IsEqual, StringRepeat} from 'type-fest'; type HundredZeroes = StringRepeat<'0', 100>; // The following implementation is not tail recursive type Includes = S extends `${infer First}${infer Rest}` ? If, 'found', Includes> : 'not found'; // Hence, instantiations with long strings will fail // @ts-expect-error type Fails = Includes; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Error: Type instantiation is excessively deep and possibly infinite. // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive type IncludesWithoutIf = S extends `${infer First}${infer Rest}` ? IsEqual extends true ? 'found' : IncludesWithoutIf : 'not found'; // Now, instantiations with long strings will work type Works = IncludesWithoutIf; //=> 'not found' ``` @category Type Guard @category Utilities */ type If = IsNever extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch; /** Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability. @example ``` import type {Simplify} from 'type-fest'; type PositionProps = { top: number; left: number; }; type SizeProps = { width: number; height: number; }; // In your editor, hovering over `Props` will show a flattened object with all the properties. type Props = Simplify; ``` Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface. If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify` if you can't re-declare the `value`. @example ``` import type {Simplify} from 'type-fest'; interface SomeInterface { foo: number; bar?: string; baz: number | undefined; } type SomeType = { foo: number; bar?: string; baz: number | undefined; }; const literal = {foo: 123, bar: 'hello', baz: 456}; const someType: SomeType = literal; const someInterface: SomeInterface = literal; declare function fn(object: Record): void; fn(literal); // Good: literal object type is sealed fn(someType); // Good: type is sealed // @ts-expect-error fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened fn(someInterface as Simplify); // Good: transform an `interface` into a `type` ``` @link https://github.com/microsoft/TypeScript/issues/15300 @see {@link SimplifyDeep} @category Object */ type Simplify = {[KeyType in keyof T]: T[KeyType]} & {}; /** Returns a boolean for whether the two given types are equal. @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650 @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796 Use-cases: - If you want to make a conditional branch based on the result of a comparison of two types. @example ``` import type {IsEqual} from 'type-fest'; // This type returns a boolean for whether the given array includes the given item. // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal. type Includes = Value extends readonly [Value[0], ...infer rest] ? IsEqual extends true ? true : Includes : false; ``` @category Type Guard @category Utilities */ type IsEqual = [A] extends [B] ? [B] extends [A] ? _IsEqual : false : false; // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`. type _IsEqual = (() => G extends A & G | G ? 1 : 2) extends (() => G extends B & G | G ? 1 : 2) ? true : false; /** Omit any index signatures from the given object type, leaving only explicitly defined properties. This is the counterpart of `PickIndexSignature`. Use-cases: - Remove overly permissive signatures from third-party types. This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747). It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`. (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.) ``` const indexed: Record = {}; // Allowed // @ts-expect-error const keyed: Record<'foo', unknown> = {}; // Error // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar ``` Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another: ``` type Indexed = {} extends Record ? '✅ `{}` is assignable to `Record`' : '❌ `{}` is NOT assignable to `Record`'; type IndexedResult = Indexed; //=> '✅ `{}` is assignable to `Record`' type Keyed = {} extends Record<'foo' | 'bar', unknown> ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`' : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'; type KeyedResult = Keyed; //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`' ``` Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`... ``` type OmitIndexSignature = { [KeyType in keyof ObjectType // Map each key of `ObjectType`... ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature == Foo`. }; ``` ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record`)... ``` type OmitIndexSignature = { [KeyType in keyof ObjectType // Is `{}` assignable to `Record`? as {} extends Record ? never // ✅ `{}` is assignable to `Record` : KeyType // ❌ `{}` is NOT assignable to `Record` ]: ObjectType[KeyType]; }; ``` If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it. @example ``` import type {OmitIndexSignature} from 'type-fest'; type Example = { // These index signatures will be removed. [x: string]: any; [x: number]: any; [x: symbol]: any; [x: `head-${string}`]: string; [x: `${string}-tail`]: string; [x: `head-${string}-tail`]: string; [x: `${bigint}`]: string; [x: `embedded-${number}`]: string; // These explicitly defined keys will remain. foo: 'bar'; qux?: 'baz'; }; type ExampleWithoutIndexSignatures = OmitIndexSignature; //=> {foo: 'bar'; qux?: 'baz'} ``` @see {@link PickIndexSignature} @category Object */ type OmitIndexSignature = { [KeyType in keyof ObjectType as {} extends Record ? never : KeyType]: ObjectType[KeyType]; }; /** Pick only index signatures from the given object type, leaving out all explicitly defined properties. This is the counterpart of `OmitIndexSignature`. @example ``` import type {PickIndexSignature} from 'type-fest'; declare const symbolKey: unique symbol; type Example = { // These index signatures will remain. [x: string]: unknown; [x: number]: unknown; [x: symbol]: unknown; [x: `head-${string}`]: string; [x: `${string}-tail`]: string; [x: `head-${string}-tail`]: string; [x: `${bigint}`]: string; [x: `embedded-${number}`]: string; // These explicitly defined keys will be removed. ['kebab-case-key']: string; [symbolKey]: string; foo: 'bar'; qux?: 'baz'; }; type ExampleIndexSignature = PickIndexSignature; // { // [x: string]: unknown; // [x: number]: unknown; // [x: symbol]: unknown; // [x: `head-${string}`]: string; // [x: `${string}-tail`]: string; // [x: `head-${string}-tail`]: string; // [x: `${bigint}`]: string; // [x: `embedded-${number}`]: string; // } ``` @see {@link OmitIndexSignature} @category Object */ type PickIndexSignature = { [KeyType in keyof ObjectType as {} extends Record ? KeyType : never]: ObjectType[KeyType]; }; // Merges two objects without worrying about index signatures. type SimpleMerge = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>; /** Merge two types into a new type. Keys of the second type overrides keys of the first type. This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`. @example ``` import type {Merge} from 'type-fest'; type Foo = { a: string; b: number; }; type Bar = { a: number; // Conflicts with Foo['a'] c: boolean; }; // With `&`, `a` becomes `string & number` which is `never`. Not what you want. type WithIntersection = (Foo & Bar)['a']; //=> never // With `Merge`, `a` is cleanly overridden to `number`. type WithMerge = Merge['a']; //=> number ``` @example ``` import type {Merge} from 'type-fest'; type Foo = { [x: string]: unknown; [x: number]: unknown; foo: string; bar: symbol; }; type Bar = { [x: number]: number; [x: symbol]: unknown; bar: Date; baz: boolean; }; export type FooBar = Merge; //=> { // [x: string]: unknown; // [x: number]: number; // [x: symbol]: unknown; // foo: string; // bar: Date; // baz: boolean; // } ``` Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type. @see {@link ObjectMerge} @category Object */ type Merge = Destination extends unknown // For distributing `Destination` ? Source extends unknown // For distributing `Source` ? If, Destination, _Merge> : never // Should never happen : never; // Should never happen type _Merge = Simplify< SimpleMerge, PickIndexSignature> & SimpleMerge, OmitIndexSignature> >; /** Works similar to the built-in `Pick` utility type, except for the following differences: - Distributes over union types and allows picking keys from any member of the union type. - Primitives types are returned as-is. - Picks all keys if `Keys` is `any`. - Doesn't pick `number` from a `string` index signature. @example ``` type ImageUpload = { url: string; size: number; thumbnailUrl: string; }; type VideoUpload = { url: string; duration: number; encodingFormat: string; }; // Distributes over union types and allows picking keys from any member of the union type type MediaDisplay = HomomorphicPick; //=> {url: string; size: number} | {url: string; duration: number} // Primitive types are returned as-is type Primitive = HomomorphicPick; //=> string | number // Picks all keys if `Keys` is `any` type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>; //=> {a: 1; b: 2} | {c: 3} // Doesn't pick `number` from a `string` index signature type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>; //=> {} */ type HomomorphicPick> = { [P in keyof T as Extract]: T[P] }; /** Merges user specified options with default options. @example ``` type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean}; type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false}; type SpecifiedOptions = {leavesOnly: true}; type Result = ApplyDefaultOptions; //=> {maxRecursionDepth: 10; leavesOnly: true} ``` @example ``` // Complains if default values are not provided for optional options type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean}; type DefaultPathsOptions = {maxRecursionDepth: 10}; type SpecifiedOptions = {}; type Result = ApplyDefaultOptions; // ~~~~~~~~~~~~~~~~~~~ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'. ``` @example ``` // Complains if an option's default type does not conform to the expected type type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean}; type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'}; type SpecifiedOptions = {}; type Result = ApplyDefaultOptions; // ~~~~~~~~~~~~~~~~~~~ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'. ``` @example ``` // Complains if an option's specified type does not conform to the expected type type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean}; type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false}; type SpecifiedOptions = {leavesOnly: 'yes'}; type Result = ApplyDefaultOptions; // ~~~~~~~~~~~~~~~~ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'. ``` */ type ApplyDefaultOptions< Options extends object, Defaults extends Simplify, RequiredKeysOf> & Partial, never>>>, SpecifiedOptions extends Options, > = If, Defaults, If, Defaults, Simplify ? undefined extends SpecifiedOptions[Key] ? never : Key : Key ]: SpecifiedOptions[Key] }> & Required>>>; /** Filter out keys from an object. Returns `never` if `Exclude` is strictly equal to `Key`. Returns `never` if `Key` extends `Exclude`. Returns `Key` otherwise. @example ``` type Filtered = Filter<'foo', 'foo'>; //=> never ``` @example ``` type Filtered = Filter<'bar', string>; //=> never ``` @example ``` type Filtered = Filter<'bar', 'foo'>; //=> 'bar' ``` @see {Except} */ type Filter = IsEqual extends true ? never : (KeyType extends ExcludeType ? never : KeyType); type ExceptOptions = { /** Disallow assigning non-specified properties. Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`. @default false */ requireExactProps?: boolean; }; type DefaultExceptOptions = { requireExactProps: false; }; /** Create a type from an object type without certain keys. We recommend setting the `requireExactProps` option to `true`. This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically. This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)). @example ``` import type {Except} from 'type-fest'; type Foo = { a: number; b: string; }; type FooWithoutA = Except; //=> {b: string} // @ts-expect-error const fooWithoutA: FooWithoutA = {a: 1, b: '2'}; // errors: 'a' does not exist in type '{ b: string; }' type FooWithoutB = Except; //=> {a: number} & Partial> // @ts-expect-error const fooWithoutB: FooWithoutB = {a: 1, b: '2'}; // errors at 'b': Type 'string' is not assignable to type 'undefined'. // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures. // Consider the following example: type UserData = { [metadata: string]: string; email: string; name: string; role: 'admin' | 'user'; }; // `Omit` clearly doesn't behave as expected in this case: type PostPayload = Omit; //=> {[x: string]: string; [x: number]: string} // In situations like this, `Except` works better. // It simply removes the `email` key while preserving all the other keys. type PostPayloadFixed = Except; //=> {[x: string]: string; name: string; role: 'admin' | 'user'} ``` @category Object */ type Except = _Except>; type _Except> = { [KeyType in keyof ObjectType as Filter]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial> : {}); /** Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type. Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are optional. @example ``` import type {SetOptional} from 'type-fest'; type Foo = { a: number; b?: string; c: boolean; }; type SomeOptional = SetOptional; //=> {a: number; b?: string; c?: boolean} ``` @category Object */ type SetOptional = (BaseType extends (...arguments_: never) => any ? (...arguments_: Parameters) => ReturnType : unknown) & _SetOptional; type _SetOptional = BaseType extends unknown // To distribute `BaseType` when it's a union type. ? Simplify< // Pick just the keys that are readonly from the base type. Except & // Pick the keys that should be mutable from the base type and make them mutable. Partial> > : never; /** * Metadata to configure the stories for a component. * * @see [Default export](https://storybook.js.org/docs/api/csf#default-export) */ type Meta = [TCmpOrArgs] extends [Component] ? ComponentAnnotations> : ComponentAnnotations; /** * Story function that represents a CSFv2 component example. * * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports) */ type StoryFn = [TCmpOrArgs] extends [Component] ? AnnotatedStoryFn> : AnnotatedStoryFn; /** * Story object that represents a CSFv3 component example. * * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports) */ type StoryObj = [TMetaOrCmpOrArgs] extends [ { render?: ArgsStoryFn; component?: infer Component; args?: infer DefaultArgs; } ] ? Simplify<(Component extends Component ? ComponentProps : unknown) & ArgsFromMeta> extends infer TArgs ? StoryAnnotations, SetOptional> : never : [TMetaOrCmpOrArgs] extends [Component] ? StoryAnnotations> : StoryAnnotations; type AddMocks = Simplify<{ [T in keyof TArgs]: T extends keyof DefaultArgs ? DefaultArgs[T] extends (...args: any) => any & { mock: object; } ? DefaultArgs[T] : TArgs[T] : TArgs[T]; }>; type Decorator = DecoratorFunction & { [IS_SOLID_JSX_FLAG]?: boolean; }; type Loader = LoaderFunction; type Preview = ProjectAnnotations; type StoryContext = StoryContext$1 & { renderToCanvas: () => Promise; }; type RenderContext = RenderContext$1; /** * Flag used to mark decorators that return JSX elements. * Decorators with this flag will be skipped on subsequent renders * to prevent double-rendering issues in SolidJS. */ declare const IS_SOLID_JSX_FLAG = "__isJSX"; /** * Applies decorators to a story function, with special handling for JSX-returning decorators. * * This function wraps decorators to prevent double-rendering when a story is already rendered. * If a decorator is marked with `IS_SOLID_JSX_FLAG`, it will be skipped on subsequent renders * to avoid re-executing JSX-returning decorators that have already been rendered. * * @param storyFn - The story function to apply decorators to * @param _decorators - Array of decorators to apply to the story * @returns A decorated story function */ declare const applyDecorators: (storyFn: LegacyStoryFn, _decorators: Decorator[]) => LegacyStoryFn; /** * Creates a decorator with proper type safety. * * Use this for decorators that don't return JSX (e.g., they only call `Story()`). * This helper ensures type safety for your decorators. * * @param decorator - The decorator function * @returns The same decorator with proper typing */ declare const createDecorator: (decorator: DecoratorFunction) => Decorator; /** * Creates a decorator that is marked as returning JSX. * * This helper function marks a decorator with the `IS_SOLID_JSX_FLAG` flag, * indicating that the decorator returns JSX elements. This flag is used by * `applyDecorators` to prevent double-rendering of JSX-returning decorators. * * @param decorator - The decorator function that returns JSX * @returns The same decorator, marked with the JSX flag */ declare const createJSXDecorator: (decorator: DecoratorFunction) => Decorator; export { type AddMocks as A, type Decorator as D, IS_SOLID_JSX_FLAG as I, type Loader as L, type Meta as M, type OmitIndexSignature as O, type Preview as P, type RenderContext as R, type StoryFn as S, type UnionToIntersection as U, createJSXDecorator as a, type StoryObj as b, createDecorator as c, type StoryContext as d, applyDecorators as e, type Simplify as f, type SetOptional as g };