@storybook/angular-vite 0.0.0-canary-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1343 @@
1
+ import { WebRenderer, Parameters as Parameters$2, Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations, StrictArgs, DecoratorFunction, LoaderFunction, StoryContext as StoryContext$1, ProjectAnnotations, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Renderer, ArgsStoryFn, StorybookConfig as StorybookConfig$1, CompatibleString } from 'storybook/internal/types';
2
+ export { ArgTypes, Args, Parameters, StrictArgs } from 'storybook/internal/types';
3
+ import * as AngularCore from '@angular/core';
4
+ import { Provider, ApplicationConfig, Type } from '@angular/core';
5
+ import { PreviewAddon, InferTypes, AddonTypes, Preview as Preview$1, Meta as Meta$1, Story } from 'storybook/internal/csf';
6
+ import { BuilderOptions, StorybookConfigVite } from '@storybook/builder-vite';
7
+
8
+ interface NgModuleMetadata {
9
+ /** List of components, directives, and pipes that belong to your component. */
10
+ declarations?: any[];
11
+ entryComponents?: any[];
12
+ /**
13
+ * List of modules that should be available to the root Storybook Component and all its children.
14
+ * If you want to register application providers or if you want to use the forRoot() pattern,
15
+ * please use the `applicationConfig` decorator in combination with the importProvidersFrom helper
16
+ * function from @angular/core instead.
17
+ */
18
+ imports?: any[];
19
+ schemas?: any[];
20
+ /**
21
+ * List of providers that should be available on the root component and all its children. Use the
22
+ * `applicationConfig` decorator to register environemt and application-wide providers.
23
+ */
24
+ providers?: Provider[];
25
+ }
26
+ interface ICollection {
27
+ [p: string]: any;
28
+ }
29
+ interface StoryFnAngularReturnType {
30
+ props?: ICollection;
31
+ moduleMetadata?: NgModuleMetadata;
32
+ applicationConfig?: ApplicationConfig;
33
+ template?: string;
34
+ styles?: string[];
35
+ userDefinedTemplate?: boolean;
36
+ }
37
+ interface AngularRenderer extends WebRenderer {
38
+ component: any;
39
+ storyResult: StoryFnAngularReturnType;
40
+ }
41
+ type Parameters$1 = Parameters$2 & {
42
+ bootstrapModuleOptions?: unknown;
43
+ };
44
+
45
+ /**
46
+ * Metadata to configure the stories for a component.
47
+ *
48
+ * @see [Default export](https://storybook.js.org/docs/api/csf#default-export)
49
+ */
50
+ type Meta<TArgs = Args> = ComponentAnnotations<AngularRenderer, TransformComponentType<TArgs>>;
51
+ /**
52
+ * Story function that represents a CSFv2 component example.
53
+ *
54
+ * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
55
+ */
56
+ type StoryFn<TArgs = Args> = AnnotatedStoryFn<AngularRenderer, TransformComponentType<TArgs>>;
57
+ /**
58
+ * Story object that represents a CSFv3 component example.
59
+ *
60
+ * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
61
+ */
62
+ type StoryObj<TArgs = Args> = StoryAnnotations<AngularRenderer, TransformComponentType<TArgs>>;
63
+ type Decorator<TArgs = StrictArgs> = DecoratorFunction<AngularRenderer, TArgs>;
64
+ type Loader<TArgs = StrictArgs> = LoaderFunction<AngularRenderer, TArgs>;
65
+ type StoryContext<TArgs = StrictArgs> = StoryContext$1<AngularRenderer, TArgs>;
66
+ type Preview = ProjectAnnotations<AngularRenderer>;
67
+ /**
68
+ * Transforms InputSignal, ModelSignal, OutputEmitterRef and EventEmitter member
69
+ * types into the values/handlers Storybook args expect.
70
+ *
71
+ * Do NOT reorder: `TransformModelSignalType` must stay innermost. It synthesizes
72
+ * the `${K}Change` output key before the outer transforms run, and because
73
+ * `ModelSignal<T> extends InputSignal<T>` the model value field is then
74
+ * idempotently re-collapsed by `TransformInputSignalType` to the same type.
75
+ */
76
+ type TransformComponentType<T> = TransformInputSignalType<TransformOutputSignalType<TransformEventType<TransformModelSignalType<T>>>>;
77
+ type AngularInputSignal<T> = AngularCore.InputSignal<T>;
78
+ type AngularInputSignalWithTransform<T, U> = AngularCore.InputSignalWithTransform<T, U>;
79
+ type AngularOutputEmitterRef<T> = AngularCore.OutputEmitterRef<T>;
80
+ type AngularModelSignal<T> = AngularCore.ModelSignal<T>;
81
+ type AngularHasInputSignal = typeof AngularCore extends {
82
+ input: infer U;
83
+ } ? true : false;
84
+ type AngularHasOutputSignal = typeof AngularCore extends {
85
+ output: infer U;
86
+ } ? true : false;
87
+ type AngularHasModelSignal = typeof AngularCore extends {
88
+ model: infer U;
89
+ } ? true : false;
90
+ type InputSignal<T> = AngularHasInputSignal extends true ? AngularInputSignal<T> : never;
91
+ type InputSignalWithTransform<T, U> = AngularHasInputSignal extends true ? AngularInputSignalWithTransform<T, U> : never;
92
+ type OutputEmitterRef<T> = AngularHasOutputSignal extends true ? AngularOutputEmitterRef<T> : never;
93
+ type ModelSignal<T> = AngularHasModelSignal extends true ? AngularModelSignal<T> : never;
94
+ type TransformInputSignalType<T> = {
95
+ [K in keyof T]: T[K] extends InputSignal<infer E> ? E : T[K] extends InputSignalWithTransform<any, infer U> ? U : T[K];
96
+ };
97
+ type TransformOutputSignalType<T> = {
98
+ [K in keyof T]: T[K] extends OutputEmitterRef<infer E> ? (e: E) => void : T[K];
99
+ };
100
+ type TransformModelSignalType<T> = {
101
+ [K in keyof T]: T[K] extends ModelSignal<infer E> ? E : T[K];
102
+ } & {
103
+ [K in keyof T as T[K] extends ModelSignal<infer _E> ? `${K & string}Change` : never]: T[K] extends ModelSignal<infer E> ? (e: E) => void : never;
104
+ };
105
+ type TransformEventType<T> = {
106
+ [K in keyof T]: T[K] extends AngularCore.EventEmitter<infer E> ? (e: E) => void : T[K];
107
+ };
108
+
109
+ /**
110
+ * Function that sets the globalConfig of your storybook. The global config is the preview module of
111
+ * your .storybook folder.
112
+ *
113
+ * It should be run a single time, so that your global config (e.g. decorators) is applied to your
114
+ * stories when using `composeStories` or `composeStory`.
115
+ *
116
+ * Example:
117
+ *
118
+ * ```jsx
119
+ * // setup-file.js
120
+ * import { setProjectAnnotations } from '@storybook/angular-vite';
121
+ *
122
+ * import projectAnnotations from './.storybook/preview';
123
+ *
124
+ * setProjectAnnotations(projectAnnotations);
125
+ * ```
126
+ *
127
+ * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')
128
+ */
129
+ declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<AngularRenderer>;
130
+
131
+ /**
132
+ Convert a union type to an intersection type.
133
+
134
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
135
+
136
+ @example
137
+ ```
138
+ import type {UnionToIntersection} from 'type-fest';
139
+
140
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
141
+
142
+ type Intersection = UnionToIntersection<Union>;
143
+ //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
144
+ ```
145
+
146
+ @category Type
147
+ */
148
+ type UnionToIntersection<Union> = (
149
+ // `extends unknown` is always going to be the case and is used to convert the
150
+ // `Union` into a [distributive conditional
151
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
152
+ Union extends unknown
153
+ // The union type is used as the only argument to a function since the union
154
+ // of function arguments is an intersection.
155
+ ? (distributedUnion: Union) => void
156
+ // This won't happen.
157
+ : never
158
+ // Infer the `Intersection` type since TypeScript represents the positional
159
+ // arguments of unions of functions as an intersection of the union.
160
+ ) extends ((mergedIntersection: infer Intersection) => void)
161
+ // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
162
+ ? Intersection & Union
163
+ : never;
164
+
165
+ /**
166
+ Create a union of all keys from a given type, even those exclusive to specific union members.
167
+
168
+ Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
169
+
170
+ @link https://stackoverflow.com/a/49402091
171
+
172
+ @example
173
+ ```
174
+ import type {KeysOfUnion} from 'type-fest';
175
+
176
+ type A = {
177
+ common: string;
178
+ a: number;
179
+ };
180
+
181
+ type B = {
182
+ common: string;
183
+ b: string;
184
+ };
185
+
186
+ type C = {
187
+ common: string;
188
+ c: boolean;
189
+ };
190
+
191
+ type Union = A | B | C;
192
+
193
+ type CommonKeys = keyof Union;
194
+ //=> 'common'
195
+
196
+ type AllKeys = KeysOfUnion<Union>;
197
+ //=> 'common' | 'a' | 'b' | 'c'
198
+ ```
199
+
200
+ @category Object
201
+ */
202
+ type KeysOfUnion<ObjectType> =
203
+ // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
204
+ keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
205
+
206
+ /**
207
+ Returns a boolean for whether the given type is `any`.
208
+
209
+ @link https://stackoverflow.com/a/49928360/1490091
210
+
211
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
212
+
213
+ @example
214
+ ```
215
+ import type {IsAny} from 'type-fest';
216
+
217
+ const typedObject = {a: 1, b: 2} as const;
218
+ const anyObject: any = {a: 1, b: 2};
219
+
220
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
221
+ return object[key];
222
+ }
223
+
224
+ const typedA = get(typedObject, 'a');
225
+ //=> 1
226
+
227
+ const anyA = get(anyObject, 'a');
228
+ //=> any
229
+ ```
230
+
231
+ @category Type Guard
232
+ @category Utilities
233
+ */
234
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
235
+
236
+ /**
237
+ Returns a boolean for whether the given key is an optional key of type.
238
+
239
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
240
+
241
+ @example
242
+ ```
243
+ import type {IsOptionalKeyOf} from 'type-fest';
244
+
245
+ type User = {
246
+ name: string;
247
+ surname: string;
248
+
249
+ luckyNumber?: number;
250
+ };
251
+
252
+ type Admin = {
253
+ name: string;
254
+ surname?: string;
255
+ };
256
+
257
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
258
+ //=> true
259
+
260
+ type T2 = IsOptionalKeyOf<User, 'name'>;
261
+ //=> false
262
+
263
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
264
+ //=> boolean
265
+
266
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
267
+ //=> false
268
+
269
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
270
+ //=> boolean
271
+ ```
272
+
273
+ @category Type Guard
274
+ @category Utilities
275
+ */
276
+ type IsOptionalKeyOf<Type extends object, Key extends keyof Type> =
277
+ IsAny<Type | Key> extends true ? never
278
+ : Key extends keyof Type
279
+ ? Type extends Record<Key, Type[Key]>
280
+ ? false
281
+ : true
282
+ : false;
283
+
284
+ /**
285
+ Extract all optional keys from the given type.
286
+
287
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
288
+
289
+ @example
290
+ ```
291
+ import type {OptionalKeysOf, Except} from 'type-fest';
292
+
293
+ type User = {
294
+ name: string;
295
+ surname: string;
296
+
297
+ luckyNumber?: number;
298
+ };
299
+
300
+ const REMOVE_FIELD = Symbol('remove field symbol');
301
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
302
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
303
+ };
304
+
305
+ const update1: UpdateOperation<User> = {
306
+ name: 'Alice',
307
+ };
308
+
309
+ const update2: UpdateOperation<User> = {
310
+ name: 'Bob',
311
+ luckyNumber: REMOVE_FIELD,
312
+ };
313
+ ```
314
+
315
+ @category Utilities
316
+ */
317
+ type OptionalKeysOf<Type extends object> =
318
+ Type extends unknown // For distributing `Type`
319
+ ? (keyof {[Key in keyof Type as
320
+ IsOptionalKeyOf<Type, Key> extends false
321
+ ? never
322
+ : Key
323
+ ]: never
324
+ }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
325
+ : never; // Should never happen
326
+
327
+ /**
328
+ Extract all required keys from the given type.
329
+
330
+ 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...
331
+
332
+ @example
333
+ ```
334
+ import type {RequiredKeysOf} from 'type-fest';
335
+
336
+ declare function createValidation<
337
+ Entity extends object,
338
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
339
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
340
+
341
+ type User = {
342
+ name: string;
343
+ surname: string;
344
+ luckyNumber?: number;
345
+ };
346
+
347
+ const validator1 = createValidation<User>('name', value => value.length < 25);
348
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
349
+
350
+ // @ts-expect-error
351
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
352
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
353
+ ```
354
+
355
+ @category Utilities
356
+ */
357
+ type RequiredKeysOf<Type extends object> =
358
+ Type extends unknown // For distributing `Type`
359
+ ? Exclude<keyof Type, OptionalKeysOf<Type>>
360
+ : never; // Should never happen
361
+
362
+ /**
363
+ Returns a boolean for whether the given type is `never`.
364
+
365
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
366
+ @link https://stackoverflow.com/a/53984913/10292952
367
+ @link https://www.zhenghao.io/posts/ts-never
368
+
369
+ Useful in type utilities, such as checking if something does not occur.
370
+
371
+ @example
372
+ ```
373
+ import type {IsNever, And} from 'type-fest';
374
+
375
+ type A = IsNever<never>;
376
+ //=> true
377
+
378
+ type B = IsNever<any>;
379
+ //=> false
380
+
381
+ type C = IsNever<unknown>;
382
+ //=> false
383
+
384
+ type D = IsNever<never[]>;
385
+ //=> false
386
+
387
+ type E = IsNever<object>;
388
+ //=> false
389
+
390
+ type F = IsNever<string>;
391
+ //=> false
392
+ ```
393
+
394
+ @example
395
+ ```
396
+ import type {IsNever} from 'type-fest';
397
+
398
+ type IsTrue<T> = T extends true ? true : false;
399
+
400
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
401
+ type A = IsTrue<never>;
402
+ //=> never
403
+
404
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
405
+ type IsTrueFixed<T> =
406
+ IsNever<T> extends true ? false : T extends true ? true : false;
407
+
408
+ type B = IsTrueFixed<never>;
409
+ //=> false
410
+ ```
411
+
412
+ @category Type Guard
413
+ @category Utilities
414
+ */
415
+ type IsNever<T> = [T] extends [never] ? true : false;
416
+
417
+ /**
418
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
419
+
420
+ Use-cases:
421
+ - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
422
+
423
+ Note:
424
+ - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
425
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
426
+
427
+ @example
428
+ ```
429
+ import type {If} from 'type-fest';
430
+
431
+ type A = If<true, 'yes', 'no'>;
432
+ //=> 'yes'
433
+
434
+ type B = If<false, 'yes', 'no'>;
435
+ //=> 'no'
436
+
437
+ type C = If<boolean, 'yes', 'no'>;
438
+ //=> 'yes' | 'no'
439
+
440
+ type D = If<any, 'yes', 'no'>;
441
+ //=> 'yes' | 'no'
442
+
443
+ type E = If<never, 'yes', 'no'>;
444
+ //=> 'no'
445
+ ```
446
+
447
+ @example
448
+ ```
449
+ import type {If, IsAny, IsNever} from 'type-fest';
450
+
451
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
452
+ //=> 'not any'
453
+
454
+ type B = If<IsNever<never>, 'is never', 'not never'>;
455
+ //=> 'is never'
456
+ ```
457
+
458
+ @example
459
+ ```
460
+ import type {If, IsEqual} from 'type-fest';
461
+
462
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
463
+
464
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
465
+ //=> 'equal'
466
+
467
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
468
+ //=> 'not equal'
469
+ ```
470
+
471
+ 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:
472
+
473
+ @example
474
+ ```
475
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
476
+
477
+ type HundredZeroes = StringRepeat<'0', 100>;
478
+
479
+ // The following implementation is not tail recursive
480
+ type Includes<S extends string, Char extends string> =
481
+ S extends `${infer First}${infer Rest}`
482
+ ? If<IsEqual<First, Char>,
483
+ 'found',
484
+ Includes<Rest, Char>>
485
+ : 'not found';
486
+
487
+ // Hence, instantiations with long strings will fail
488
+ // @ts-expect-error
489
+ type Fails = Includes<HundredZeroes, '1'>;
490
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
491
+ // Error: Type instantiation is excessively deep and possibly infinite.
492
+
493
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
494
+ type IncludesWithoutIf<S extends string, Char extends string> =
495
+ S extends `${infer First}${infer Rest}`
496
+ ? IsEqual<First, Char> extends true
497
+ ? 'found'
498
+ : IncludesWithoutIf<Rest, Char>
499
+ : 'not found';
500
+
501
+ // Now, instantiations with long strings will work
502
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
503
+ //=> 'not found'
504
+ ```
505
+
506
+ @category Type Guard
507
+ @category Utilities
508
+ */
509
+ type If<Type extends boolean, IfBranch, ElseBranch> =
510
+ IsNever<Type> extends true
511
+ ? ElseBranch
512
+ : Type extends true
513
+ ? IfBranch
514
+ : ElseBranch;
515
+
516
+ /**
517
+ 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.
518
+
519
+ @example
520
+ ```
521
+ import type {Simplify} from 'type-fest';
522
+
523
+ type PositionProps = {
524
+ top: number;
525
+ left: number;
526
+ };
527
+
528
+ type SizeProps = {
529
+ width: number;
530
+ height: number;
531
+ };
532
+
533
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
534
+ type Props = Simplify<PositionProps & SizeProps>;
535
+ ```
536
+
537
+ 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<string, unknown>`. 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.
538
+
539
+ 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<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
540
+
541
+ @example
542
+ ```
543
+ import type {Simplify} from 'type-fest';
544
+
545
+ interface SomeInterface {
546
+ foo: number;
547
+ bar?: string;
548
+ baz: number | undefined;
549
+ }
550
+
551
+ type SomeType = {
552
+ foo: number;
553
+ bar?: string;
554
+ baz: number | undefined;
555
+ };
556
+
557
+ const literal = {foo: 123, bar: 'hello', baz: 456};
558
+ const someType: SomeType = literal;
559
+ const someInterface: SomeInterface = literal;
560
+
561
+ declare function fn(object: Record<string, unknown>): void;
562
+
563
+ fn(literal); // Good: literal object type is sealed
564
+ fn(someType); // Good: type is sealed
565
+ // @ts-expect-error
566
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
567
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
568
+ ```
569
+
570
+ @link https://github.com/microsoft/TypeScript/issues/15300
571
+ @see {@link SimplifyDeep}
572
+ @category Object
573
+ */
574
+ type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
575
+
576
+ /**
577
+ Returns a boolean for whether the two given types are equal.
578
+
579
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
580
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
581
+
582
+ Use-cases:
583
+ - If you want to make a conditional branch based on the result of a comparison of two types.
584
+
585
+ @example
586
+ ```
587
+ import type {IsEqual} from 'type-fest';
588
+
589
+ // This type returns a boolean for whether the given array includes the given item.
590
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
591
+ type Includes<Value extends readonly any[], Item> =
592
+ Value extends readonly [Value[0], ...infer rest]
593
+ ? IsEqual<Value[0], Item> extends true
594
+ ? true
595
+ : Includes<rest, Item>
596
+ : false;
597
+ ```
598
+
599
+ @category Type Guard
600
+ @category Utilities
601
+ */
602
+ type IsEqual<A, B> =
603
+ [A] extends [B]
604
+ ? [B] extends [A]
605
+ ? _IsEqual<A, B>
606
+ : false
607
+ : false;
608
+
609
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
610
+ type _IsEqual<A, B> =
611
+ (<G>() => G extends A & G | G ? 1 : 2) extends
612
+ (<G>() => G extends B & G | G ? 1 : 2)
613
+ ? true
614
+ : false;
615
+
616
+ /**
617
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
618
+
619
+ This is the counterpart of `PickIndexSignature`.
620
+
621
+ Use-cases:
622
+ - Remove overly permissive signatures from third-party types.
623
+
624
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
625
+
626
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
627
+
628
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
629
+
630
+ ```
631
+ const indexed: Record<string, unknown> = {}; // Allowed
632
+
633
+ // @ts-expect-error
634
+ const keyed: Record<'foo', unknown> = {}; // Error
635
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
636
+ ```
637
+
638
+ 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:
639
+
640
+ ```
641
+ type Indexed = {} extends Record<string, unknown>
642
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
643
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
644
+
645
+ type IndexedResult = Indexed;
646
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
647
+
648
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
649
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
650
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
651
+
652
+ type KeyedResult = Keyed;
653
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
654
+ ```
655
+
656
+ 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`...
657
+
658
+ ```
659
+ type OmitIndexSignature<ObjectType> = {
660
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
661
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
662
+ };
663
+ ```
664
+
665
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
666
+
667
+ ```
668
+ type OmitIndexSignature<ObjectType> = {
669
+ [KeyType in keyof ObjectType
670
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
671
+ as {} extends Record<KeyType, unknown>
672
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
673
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
674
+ ]: ObjectType[KeyType];
675
+ };
676
+ ```
677
+
678
+ 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.
679
+
680
+ @example
681
+ ```
682
+ import type {OmitIndexSignature} from 'type-fest';
683
+
684
+ type Example = {
685
+ // These index signatures will be removed.
686
+ [x: string]: any;
687
+ [x: number]: any;
688
+ [x: symbol]: any;
689
+ [x: `head-${string}`]: string;
690
+ [x: `${string}-tail`]: string;
691
+ [x: `head-${string}-tail`]: string;
692
+ [x: `${bigint}`]: string;
693
+ [x: `embedded-${number}`]: string;
694
+
695
+ // These explicitly defined keys will remain.
696
+ foo: 'bar';
697
+ qux?: 'baz';
698
+ };
699
+
700
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
701
+ //=> {foo: 'bar'; qux?: 'baz'}
702
+ ```
703
+
704
+ @see {@link PickIndexSignature}
705
+ @category Object
706
+ */
707
+ type OmitIndexSignature<ObjectType> = {
708
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
709
+ ? never
710
+ : KeyType]: ObjectType[KeyType];
711
+ };
712
+
713
+ /**
714
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
715
+
716
+ This is the counterpart of `OmitIndexSignature`.
717
+
718
+ @example
719
+ ```
720
+ import type {PickIndexSignature} from 'type-fest';
721
+
722
+ declare const symbolKey: unique symbol;
723
+
724
+ type Example = {
725
+ // These index signatures will remain.
726
+ [x: string]: unknown;
727
+ [x: number]: unknown;
728
+ [x: symbol]: unknown;
729
+ [x: `head-${string}`]: string;
730
+ [x: `${string}-tail`]: string;
731
+ [x: `head-${string}-tail`]: string;
732
+ [x: `${bigint}`]: string;
733
+ [x: `embedded-${number}`]: string;
734
+
735
+ // These explicitly defined keys will be removed.
736
+ ['kebab-case-key']: string;
737
+ [symbolKey]: string;
738
+ foo: 'bar';
739
+ qux?: 'baz';
740
+ };
741
+
742
+ type ExampleIndexSignature = PickIndexSignature<Example>;
743
+ // {
744
+ // [x: string]: unknown;
745
+ // [x: number]: unknown;
746
+ // [x: symbol]: unknown;
747
+ // [x: `head-${string}`]: string;
748
+ // [x: `${string}-tail`]: string;
749
+ // [x: `head-${string}-tail`]: string;
750
+ // [x: `${bigint}`]: string;
751
+ // [x: `embedded-${number}`]: string;
752
+ // }
753
+ ```
754
+
755
+ @see {@link OmitIndexSignature}
756
+ @category Object
757
+ */
758
+ type PickIndexSignature<ObjectType> = {
759
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
760
+ ? KeyType
761
+ : never]: ObjectType[KeyType];
762
+ };
763
+
764
+ // Merges two objects without worrying about index signatures.
765
+ type SimpleMerge<Destination, Source> = Simplify<{
766
+ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
767
+ } & Source>;
768
+
769
+ /**
770
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
771
+
772
+ 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`.
773
+
774
+ @example
775
+ ```
776
+ import type {Merge} from 'type-fest';
777
+
778
+ type Foo = {
779
+ a: string;
780
+ b: number;
781
+ };
782
+
783
+ type Bar = {
784
+ a: number; // Conflicts with Foo['a']
785
+ c: boolean;
786
+ };
787
+
788
+ // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
789
+ type WithIntersection = (Foo & Bar)['a'];
790
+ //=> never
791
+
792
+ // With `Merge`, `a` is cleanly overridden to `number`.
793
+ type WithMerge = Merge<Foo, Bar>['a'];
794
+ //=> number
795
+ ```
796
+
797
+ @example
798
+ ```
799
+ import type {Merge} from 'type-fest';
800
+
801
+ type Foo = {
802
+ [x: string]: unknown;
803
+ [x: number]: unknown;
804
+ foo: string;
805
+ bar: symbol;
806
+ };
807
+
808
+ type Bar = {
809
+ [x: number]: number;
810
+ [x: symbol]: unknown;
811
+ bar: Date;
812
+ baz: boolean;
813
+ };
814
+
815
+ export type FooBar = Merge<Foo, Bar>;
816
+ //=> {
817
+ // [x: string]: unknown;
818
+ // [x: number]: number;
819
+ // [x: symbol]: unknown;
820
+ // foo: string;
821
+ // bar: Date;
822
+ // baz: boolean;
823
+ // }
824
+ ```
825
+
826
+ 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.
827
+
828
+ @see {@link ObjectMerge}
829
+ @category Object
830
+ */
831
+ type Merge<Destination, Source> =
832
+ Destination extends unknown // For distributing `Destination`
833
+ ? Source extends unknown // For distributing `Source`
834
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>>
835
+ : never // Should never happen
836
+ : never; // Should never happen
837
+
838
+ type _Merge<Destination, Source> =
839
+ Simplify<
840
+ SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
841
+ & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
842
+ >;
843
+
844
+ /**
845
+ Works similar to the built-in `Pick` utility type, except for the following differences:
846
+ - Distributes over union types and allows picking keys from any member of the union type.
847
+ - Primitives types are returned as-is.
848
+ - Picks all keys if `Keys` is `any`.
849
+ - Doesn't pick `number` from a `string` index signature.
850
+
851
+ @example
852
+ ```
853
+ type ImageUpload = {
854
+ url: string;
855
+ size: number;
856
+ thumbnailUrl: string;
857
+ };
858
+
859
+ type VideoUpload = {
860
+ url: string;
861
+ duration: number;
862
+ encodingFormat: string;
863
+ };
864
+
865
+ // Distributes over union types and allows picking keys from any member of the union type
866
+ type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
867
+ //=> {url: string; size: number} | {url: string; duration: number}
868
+
869
+ // Primitive types are returned as-is
870
+ type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
871
+ //=> string | number
872
+
873
+ // Picks all keys if `Keys` is `any`
874
+ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
875
+ //=> {a: 1; b: 2} | {c: 3}
876
+
877
+ // Doesn't pick `number` from a `string` index signature
878
+ type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
879
+ //=> {}
880
+ */
881
+ type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = {
882
+ [P in keyof T as Extract<P, Keys>]: T[P]
883
+ };
884
+
885
+ /**
886
+ Merges user specified options with default options.
887
+
888
+ @example
889
+ ```
890
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
891
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
892
+ type SpecifiedOptions = {leavesOnly: true};
893
+
894
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
895
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
896
+ ```
897
+
898
+ @example
899
+ ```
900
+ // Complains if default values are not provided for optional options
901
+
902
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
903
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
904
+ type SpecifiedOptions = {};
905
+
906
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
907
+ // ~~~~~~~~~~~~~~~~~~~
908
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
909
+ ```
910
+
911
+ @example
912
+ ```
913
+ // Complains if an option's default type does not conform to the expected type
914
+
915
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
916
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
917
+ type SpecifiedOptions = {};
918
+
919
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
920
+ // ~~~~~~~~~~~~~~~~~~~
921
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
922
+ ```
923
+
924
+ @example
925
+ ```
926
+ // Complains if an option's specified type does not conform to the expected type
927
+
928
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
929
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
930
+ type SpecifiedOptions = {leavesOnly: 'yes'};
931
+
932
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
933
+ // ~~~~~~~~~~~~~~~~
934
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
935
+ ```
936
+ */
937
+ type ApplyDefaultOptions<
938
+ Options extends object,
939
+ Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
940
+ SpecifiedOptions extends Options,
941
+ > =
942
+ If<IsAny<SpecifiedOptions>, Defaults,
943
+ If<IsNever<SpecifiedOptions>, Defaults,
944
+ Simplify<Merge<Defaults, {
945
+ [Key in keyof SpecifiedOptions
946
+ as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key
947
+ ]: SpecifiedOptions[Key]
948
+ }> & Required<Options>>>>;
949
+
950
+ /**
951
+ Filter out keys from an object.
952
+
953
+ Returns `never` if `Exclude` is strictly equal to `Key`.
954
+ Returns `never` if `Key` extends `Exclude`.
955
+ Returns `Key` otherwise.
956
+
957
+ @example
958
+ ```
959
+ type Filtered = Filter<'foo', 'foo'>;
960
+ //=> never
961
+ ```
962
+
963
+ @example
964
+ ```
965
+ type Filtered = Filter<'bar', string>;
966
+ //=> never
967
+ ```
968
+
969
+ @example
970
+ ```
971
+ type Filtered = Filter<'bar', 'foo'>;
972
+ //=> 'bar'
973
+ ```
974
+
975
+ @see {Except}
976
+ */
977
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
978
+
979
+ type ExceptOptions = {
980
+ /**
981
+ Disallow assigning non-specified properties.
982
+
983
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
984
+
985
+ @default false
986
+ */
987
+ requireExactProps?: boolean;
988
+ };
989
+
990
+ type DefaultExceptOptions = {
991
+ requireExactProps: false;
992
+ };
993
+
994
+ /**
995
+ Create a type from an object type without certain keys.
996
+
997
+ We recommend setting the `requireExactProps` option to `true`.
998
+
999
+ 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.
1000
+
1001
+ 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)).
1002
+
1003
+ @example
1004
+ ```
1005
+ import type {Except} from 'type-fest';
1006
+
1007
+ type Foo = {
1008
+ a: number;
1009
+ b: string;
1010
+ };
1011
+
1012
+ type FooWithoutA = Except<Foo, 'a'>;
1013
+ //=> {b: string}
1014
+
1015
+ // @ts-expect-error
1016
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1017
+ // errors: 'a' does not exist in type '{ b: string; }'
1018
+
1019
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1020
+ //=> {a: number} & Partial<Record<'b', never>>
1021
+
1022
+ // @ts-expect-error
1023
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1024
+ // errors at 'b': Type 'string' is not assignable to type 'undefined'.
1025
+
1026
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
1027
+
1028
+ // Consider the following example:
1029
+
1030
+ type UserData = {
1031
+ [metadata: string]: string;
1032
+ email: string;
1033
+ name: string;
1034
+ role: 'admin' | 'user';
1035
+ };
1036
+
1037
+ // `Omit` clearly doesn't behave as expected in this case:
1038
+ type PostPayload = Omit<UserData, 'email'>;
1039
+ //=> {[x: string]: string; [x: number]: string}
1040
+
1041
+ // In situations like this, `Except` works better.
1042
+ // It simply removes the `email` key while preserving all the other keys.
1043
+ type PostPayloadFixed = Except<UserData, 'email'>;
1044
+ //=> {[x: string]: string; name: string; role: 'admin' | 'user'}
1045
+ ```
1046
+
1047
+ @category Object
1048
+ */
1049
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> =
1050
+ _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
1051
+
1052
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = {
1053
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
1054
+ } & (Options['requireExactProps'] extends true
1055
+ ? Partial<Record<KeysType, never>>
1056
+ : {});
1057
+
1058
+ /**
1059
+ Create a type that makes the given keys optional, while keeping the remaining keys as is.
1060
+
1061
+ 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.
1062
+
1063
+ @example
1064
+ ```
1065
+ import type {SetOptional} from 'type-fest';
1066
+
1067
+ type Foo = {
1068
+ a: number;
1069
+ b?: string;
1070
+ c: boolean;
1071
+ };
1072
+
1073
+ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
1074
+ //=> {a: number; b?: string; c?: boolean}
1075
+ ```
1076
+
1077
+ @category Object
1078
+ */
1079
+ type SetOptional<BaseType, Keys extends keyof BaseType> =
1080
+ (BaseType extends (...arguments_: never) => any
1081
+ ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType>
1082
+ : unknown)
1083
+ & _SetOptional<BaseType, Keys>;
1084
+
1085
+ type _SetOptional<BaseType, Keys extends keyof BaseType> =
1086
+ BaseType extends unknown // To distribute `BaseType` when it's a union type.
1087
+ ? Simplify<
1088
+ // Pick just the keys that are readonly from the base type.
1089
+ Except<BaseType, Keys>
1090
+ // Pick the keys that should be mutable from the base type and make them mutable.
1091
+ & Partial<HomomorphicPick<BaseType, Keys>>
1092
+ >
1093
+ : never;
1094
+
1095
+ /**
1096
+ * Creates an Angular-specific preview configuration with CSF factories support.
1097
+ *
1098
+ * This function wraps the base `definePreview` and adds Angular-specific annotations for rendering
1099
+ * and documentation. It returns an `AngularPreview` that provides type-safe `meta()` and `story()`
1100
+ * factory methods.
1101
+ *
1102
+ * @example
1103
+ *
1104
+ * ```ts
1105
+ * // .storybook/preview.ts
1106
+ * import { definePreview } from '@storybook/angular-vite';
1107
+ *
1108
+ * export const preview = definePreview({
1109
+ * addons: [],
1110
+ * parameters: { layout: 'centered' },
1111
+ * });
1112
+ * ```
1113
+ */
1114
+ declare function __definePreview<Addons extends PreviewAddon<never>[]>(input: {
1115
+ addons: Addons;
1116
+ } & ProjectAnnotations<AngularRenderer & InferTypes<Addons>>): AngularPreview<AngularRenderer & InferTypes<Addons>>;
1117
+ type InferArgs<TArgs, T, Decorators> = Simplify<TArgs & Simplify<OmitIndexSignature<DecoratorsArgs<AngularRenderer & T, Decorators>>>>;
1118
+ type InferComponentArgs<C extends abstract new (...args: any) => any> = Partial<TransformComponentType<InstanceType<C>>>;
1119
+ type InferAngularTypes<T, TArgs, Decorators> = AngularRenderer & T & {
1120
+ args: Simplify<InferArgs<TArgs, T, Decorators>>;
1121
+ };
1122
+ /**
1123
+ * Angular-specific Preview interface that provides type-safe CSF factory methods.
1124
+ *
1125
+ * Use `preview.meta()` to create a meta configuration for a component, and then `meta.story()` to
1126
+ * create individual stories. The type system will infer args from the component, decorators, and
1127
+ * any addon types.
1128
+ *
1129
+ * @example
1130
+ *
1131
+ * ```ts
1132
+ * const meta = preview.meta({ component: ButtonComponent });
1133
+ * export const Primary = meta.story({ args: { label: 'Click me' } });
1134
+ * ```
1135
+ */
1136
+ interface AngularPreview<T extends AddonTypes> extends Preview$1<AngularRenderer & T> {
1137
+ /**
1138
+ * Narrows the type of the preview to include additional type information. This is useful when you
1139
+ * need to add args that aren't inferred from the component.
1140
+ *
1141
+ * @example
1142
+ *
1143
+ * ```ts
1144
+ * const meta = preview.type<{ args: { theme: 'light' | 'dark' } }>().meta({
1145
+ * component: ButtonComponent,
1146
+ * });
1147
+ * ```
1148
+ */
1149
+ type<S>(): AngularPreview<T & S>;
1150
+ meta<C extends abstract new (...args: any) => any, Decorators extends DecoratorFunction<AngularRenderer & T, any>, TMetaArgs extends Partial<InferComponentArgs<C> & T['args']>>(meta: {
1151
+ component?: C;
1152
+ args?: TMetaArgs;
1153
+ decorators?: Decorators | Decorators[];
1154
+ } & Omit<ComponentAnnotations<AngularRenderer & T, InferComponentArgs<C> & T['args']>, 'decorators' | 'component' | 'args'>): AngularMeta<InferAngularTypes<T, InferComponentArgs<C>, Decorators>, Omit<ComponentAnnotations<InferAngularTypes<T, InferComponentArgs<C>, Decorators>>, 'args'> & {
1155
+ args: {} extends TMetaArgs ? {} : TMetaArgs;
1156
+ }>;
1157
+ meta<TArgs, Decorators extends DecoratorFunction<AngularRenderer & T, any>, TMetaArgs extends Partial<TArgs & T['args']>>(meta: {
1158
+ render?: ArgsStoryFn<AngularRenderer & T, TArgs & T['args']>;
1159
+ args?: TMetaArgs;
1160
+ decorators?: Decorators | Decorators[];
1161
+ } & Omit<ComponentAnnotations<AngularRenderer & T, TArgs & T['args']>, 'decorators' | 'args' | 'render' | 'component'>): AngularMeta<InferAngularTypes<T, TArgs, Decorators>, Omit<ComponentAnnotations<InferAngularTypes<T, TArgs, Decorators>>, 'args'> & {
1162
+ args: {} extends TMetaArgs ? {} : TMetaArgs;
1163
+ }>;
1164
+ }
1165
+ /** Extracts and unions all args types from an array of decorators. */
1166
+ type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
1167
+ /**
1168
+ * Angular-specific Meta interface returned by `preview.meta()`.
1169
+ *
1170
+ * Provides the `story()` method to create individual stories with proper type inference. Args
1171
+ * provided in meta become optional in stories, while missing required args must be provided at the
1172
+ * story level.
1173
+ */
1174
+ interface AngularMeta<T extends AngularRenderer, MetaInput extends ComponentAnnotations<T>> extends Meta$1<T, MetaInput> {
1175
+ /**
1176
+ * Creates a story with a custom render function that takes no args.
1177
+ *
1178
+ * This overload allows you to define a story using just a render function or an object with a
1179
+ * render function that doesn't depend on args. Since the render function doesn't use args, no
1180
+ * args need to be provided regardless of what's required by the component.
1181
+ *
1182
+ * @example
1183
+ *
1184
+ * ```ts
1185
+ * // Using just a render function
1186
+ * export const CustomTemplate = meta.story(() => ({
1187
+ * template: '<div>Custom static content</div>',
1188
+ * }));
1189
+ *
1190
+ * // Using an object with render
1191
+ * export const WithRender = meta.story({
1192
+ * render: () => ({ template: '<my-component></my-component>' }),
1193
+ * });
1194
+ * ```
1195
+ */
1196
+ story<TInput extends (() => AngularRenderer['storyResult']) | (StoryAnnotations<T, T['args']> & {
1197
+ render: () => AngularRenderer['storyResult'];
1198
+ })>(story: TInput): AngularStory<T, TInput extends () => AngularRenderer['storyResult'] ? {
1199
+ render: TInput;
1200
+ } : TInput>;
1201
+ /**
1202
+ * Creates a story with custom configuration including args, decorators, or other annotations.
1203
+ *
1204
+ * This is the primary overload for defining stories. Args that were already provided in meta
1205
+ * become optional, while any remaining required args must be specified here.
1206
+ *
1207
+ * @example
1208
+ *
1209
+ * ```ts
1210
+ * // Provide required args not in meta
1211
+ * export const Primary = meta.story({
1212
+ * args: { label: 'Click me', disabled: false },
1213
+ * });
1214
+ *
1215
+ * // Override meta args and add story-specific configuration
1216
+ * export const Disabled = meta.story({
1217
+ * args: { disabled: true },
1218
+ * decorators: [withCustomWrapper],
1219
+ * });
1220
+ * ```
1221
+ */
1222
+ story<TInput extends Simplify<StoryAnnotations<T, T['args'], SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']>>>>(story: TInput): AngularStory<T, TInput>;
1223
+ /**
1224
+ * Creates a story with no additional configuration.
1225
+ *
1226
+ * This overload is only available when all required args have been provided in meta. The
1227
+ * conditional type `Partial<T['args']> extends SetOptional<...>` checks if the remaining required
1228
+ * args (after accounting for args provided in meta) are all optional. If so, the function accepts
1229
+ * zero arguments `[]`. Otherwise, it requires `[never]` which makes this overload unmatchable,
1230
+ * forcing the user to provide args.
1231
+ *
1232
+ * @example
1233
+ *
1234
+ * ```ts
1235
+ * // When meta provides all required args, story() can be called with no arguments
1236
+ * const meta = preview.meta({ component: Button, args: { label: 'Hi', disabled: false } });
1237
+ * export const Default = meta.story(); // Valid - all args provided in meta
1238
+ * ```
1239
+ */
1240
+ story(..._args: Partial<T['args']> extends SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']> ? [] : [never]): AngularStory<T, {}>;
1241
+ }
1242
+ /**
1243
+ * Angular-specific Story interface returned by `meta.story()`.
1244
+ *
1245
+ * Represents a single story with its configuration and provides access to the composed story for
1246
+ * testing via `story.run()`.
1247
+ */
1248
+ interface AngularStory<T extends AngularRenderer, TInput extends StoryAnnotations<T, T['args']>> extends Story<T, TInput> {
1249
+ }
1250
+
1251
+ declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularRenderer, TArgs>;
1252
+ /**
1253
+ * Decorator to set the config options which are available during the application bootstrap
1254
+ * operation
1255
+ */
1256
+ declare function applicationConfig<TArgs = any>(
1257
+ /** Set of config options available during the application bootstrap operation. */
1258
+ config: ApplicationConfig): DecoratorFunction<AngularRenderer, TArgs>;
1259
+ declare const componentWrapperDecorator: <TArgs = any>(element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext$1<AngularRenderer, TArgs>) => ICollection)) => DecoratorFunction<AngularRenderer, TArgs>;
1260
+
1261
+ /**
1262
+ * Options for controlling the behavior of the argsToTemplate function.
1263
+ *
1264
+ * @template T The type of the keys in the target object.
1265
+ */
1266
+ interface ArgsToTemplateOptions<T> {
1267
+ /**
1268
+ * An array of keys to specifically include in the output. If provided, only the keys from this
1269
+ * array will be included in the output, irrespective of the `exclude` option. Undefined values
1270
+ * will still be excluded from the output.
1271
+ */
1272
+ include?: Array<T>;
1273
+ /**
1274
+ * An array of keys to specifically exclude from the output. If provided, these keys will be
1275
+ * omitted from the output. This option is ignored if the `include` option is also provided
1276
+ */
1277
+ exclude?: Array<T>;
1278
+ }
1279
+ /**
1280
+ * Converts an object of arguments to a string of property and event bindings and excludes undefined
1281
+ * values. Why? Because Angular treats undefined values in property bindings as an actual value and
1282
+ * does not apply the default value of the property as soon as the binding is set. This feels
1283
+ * counter-intuitive and is a common source of bugs in stories.
1284
+ *
1285
+ * @example
1286
+ *
1287
+ * ```ts
1288
+ * // component.ts
1289
+ * ㅤ@Component({ selector: 'example' })
1290
+ * export class ExampleComponent {
1291
+ * ㅤ@Input() input1: string = 'Default Input1';
1292
+ * ㅤ@Input() input2: string = 'Default Input2';
1293
+ * ㅤ@Output() click = new EventEmitter();
1294
+ * }
1295
+ *
1296
+ * // component.stories.ts
1297
+ * import { argsToTemplate } from '@storybook/angular-vite';
1298
+ * export const Input1: Story = {
1299
+ * render: (args) => ({
1300
+ * props: args,
1301
+ * // Problem1: <example [input1]="input1" [input2]="input2" (click)="click($event)"></example>
1302
+ * // This will set input2 to undefined and the internal default value will not be used.
1303
+ * // Problem2: <example [input1]="input1" (click)="click($event)"></example>
1304
+ * // The default value of input2 will be used, but it is not overridable by the user via controls.
1305
+ * // Solution: Now the controls will be applicable to both input1 and input2, and the default values will be used if the user does not override them.
1306
+ * template: `<example ${argsToTemplate(args)}"></example>`,
1307
+ * }),
1308
+ * args: {
1309
+ * // In this Story, we want to set the input1 property, and the internal default property of input2 should be used.
1310
+ * input1: 'Input 1',
1311
+ * click: { action: 'clicked' },
1312
+ * },
1313
+ * };
1314
+ * ```
1315
+ */
1316
+ declare function argsToTemplate<A extends Record<string, any>>(args: A, options?: ArgsToTemplateOptions<keyof A>): string;
1317
+
1318
+ type FrameworkName = CompatibleString<'@storybook/angular-vite'>;
1319
+ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
1320
+ type FrameworkOptions = {
1321
+ builder?: BuilderOptions;
1322
+ jit?: boolean;
1323
+ liveReload?: boolean;
1324
+ inlineStylesExtension?: string;
1325
+ tsconfig?: string;
1326
+ zoneless?: boolean;
1327
+ };
1328
+ type StorybookConfigFramework = {
1329
+ framework: FrameworkName | {
1330
+ name: FrameworkName;
1331
+ options: FrameworkOptions;
1332
+ };
1333
+ core?: StorybookConfig$1['core'] & {
1334
+ builder?: BuilderName | {
1335
+ name: BuilderName;
1336
+ options: BuilderOptions;
1337
+ };
1338
+ };
1339
+ };
1340
+ /** The interface for Storybook configuration in `main.ts` files. */
1341
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigVite | keyof StorybookConfigFramework> & StorybookConfigVite & StorybookConfigFramework;
1342
+
1343
+ export { type AngularMeta, type Parameters$1 as AngularParameters, type AngularPreview, type AngularRenderer, type AngularStory, type Decorator, type FrameworkOptions, type StoryFnAngularReturnType as IStory, type Loader, type Meta, type Preview, type StoryContext, type StoryFn, type StoryObj, type StorybookConfig, type TransformComponentType, __definePreview, applicationConfig, argsToTemplate, componentWrapperDecorator, __definePreview as definePreview, moduleMetadata, setProjectAnnotations };