@visulima/tsconfig 3.2.7 → 3.2.8

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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,1606 @@
1
- import { TsConfigJson, Except } from 'type-fest';
2
- export type { TsConfigJson } from 'type-fest';
3
1
  import { WriteJsonOptions } from '@visulima/fs';
2
+ /**
3
+ Returns a boolean for whether the given type is `any`.
4
+
5
+ @link https://stackoverflow.com/a/49928360/1490091
6
+
7
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
8
+
9
+ @example
10
+ ```
11
+ import type {IsAny} from 'type-fest';
12
+
13
+ const typedObject = {a: 1, b: 2} as const;
14
+ const anyObject: any = {a: 1, b: 2};
15
+
16
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
17
+ return object[key];
18
+ }
19
+
20
+ const typedA = get(typedObject, 'a');
21
+ //=> 1
22
+
23
+ const anyA = get(anyObject, 'a');
24
+ //=> any
25
+ ```
26
+
27
+ @category Type Guard
28
+ @category Utilities
29
+ */
30
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
31
+ /**
32
+ Returns a boolean for whether the given key is an optional key of type.
33
+
34
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
35
+
36
+ @example
37
+ ```
38
+ import type {IsOptionalKeyOf} from 'type-fest';
39
+
40
+ type User = {
41
+ name: string;
42
+ surname: string;
43
+
44
+ luckyNumber?: number;
45
+ };
46
+
47
+ type Admin = {
48
+ name: string;
49
+ surname?: string;
50
+ };
51
+
52
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
53
+ //=> true
54
+
55
+ type T2 = IsOptionalKeyOf<User, 'name'>;
56
+ //=> false
57
+
58
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
59
+ //=> boolean
60
+
61
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
62
+ //=> false
63
+
64
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
65
+ //=> boolean
66
+ ```
67
+
68
+ @category Type Guard
69
+ @category Utilities
70
+ */
71
+ type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
72
+ /**
73
+ Extract all optional keys from the given type.
74
+
75
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
76
+
77
+ @example
78
+ ```
79
+ import type {OptionalKeysOf, Except} from 'type-fest';
80
+
81
+ type User = {
82
+ name: string;
83
+ surname: string;
84
+
85
+ luckyNumber?: number;
86
+ };
87
+
88
+ const REMOVE_FIELD = Symbol('remove field symbol');
89
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
90
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
91
+ };
92
+
93
+ const update1: UpdateOperation<User> = {
94
+ name: 'Alice',
95
+ };
96
+
97
+ const update2: UpdateOperation<User> = {
98
+ name: 'Bob',
99
+ luckyNumber: REMOVE_FIELD,
100
+ };
101
+ ```
102
+
103
+ @category Utilities
104
+ */
105
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
106
+ ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never; }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
107
+ : never; // Should never happen
108
+ /**
109
+ Extract all required keys from the given type.
110
+
111
+ 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...
112
+
113
+ @example
114
+ ```
115
+ import type {RequiredKeysOf} from 'type-fest';
116
+
117
+ declare function createValidation<
118
+ Entity extends object,
119
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
120
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
121
+
122
+ type User = {
123
+ name: string;
124
+ surname: string;
125
+ luckyNumber?: number;
126
+ };
127
+
128
+ const validator1 = createValidation<User>('name', value => value.length < 25);
129
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
130
+
131
+ // @ts-expect-error
132
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
133
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
134
+ ```
135
+
136
+ @category Utilities
137
+ */
138
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
139
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
140
+ /**
141
+ Returns a boolean for whether the given type is `never`.
142
+
143
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
144
+ @link https://stackoverflow.com/a/53984913/10292952
145
+ @link https://www.zhenghao.io/posts/ts-never
146
+
147
+ Useful in type utilities, such as checking if something does not occur.
148
+
149
+ @example
150
+ ```
151
+ import type {IsNever, And} from 'type-fest';
152
+
153
+ type A = IsNever<never>;
154
+ //=> true
155
+
156
+ type B = IsNever<any>;
157
+ //=> false
158
+
159
+ type C = IsNever<unknown>;
160
+ //=> false
161
+
162
+ type D = IsNever<never[]>;
163
+ //=> false
164
+
165
+ type E = IsNever<object>;
166
+ //=> false
167
+
168
+ type F = IsNever<string>;
169
+ //=> false
170
+ ```
171
+
172
+ @example
173
+ ```
174
+ import type {IsNever} from 'type-fest';
175
+
176
+ type IsTrue<T> = T extends true ? true : false;
177
+
178
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
179
+ type A = IsTrue<never>;
180
+ //=> never
181
+
182
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
183
+ type IsTrueFixed<T> =
184
+ IsNever<T> extends true ? false : T extends true ? true : false;
185
+
186
+ type B = IsTrueFixed<never>;
187
+ //=> false
188
+ ```
189
+
190
+ @category Type Guard
191
+ @category Utilities
192
+ */
193
+ type IsNever<T> = [T] extends [never] ? true : false;
194
+ /**
195
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
196
+
197
+ Use-cases:
198
+ - 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'>`.
199
+
200
+ Note:
201
+ - 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'`.
202
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
203
+
204
+ @example
205
+ ```
206
+ import type {If} from 'type-fest';
207
+
208
+ type A = If<true, 'yes', 'no'>;
209
+ //=> 'yes'
210
+
211
+ type B = If<false, 'yes', 'no'>;
212
+ //=> 'no'
213
+
214
+ type C = If<boolean, 'yes', 'no'>;
215
+ //=> 'yes' | 'no'
216
+
217
+ type D = If<any, 'yes', 'no'>;
218
+ //=> 'yes' | 'no'
219
+
220
+ type E = If<never, 'yes', 'no'>;
221
+ //=> 'no'
222
+ ```
223
+
224
+ @example
225
+ ```
226
+ import type {If, IsAny, IsNever} from 'type-fest';
227
+
228
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
229
+ //=> 'not any'
230
+
231
+ type B = If<IsNever<never>, 'is never', 'not never'>;
232
+ //=> 'is never'
233
+ ```
234
+
235
+ @example
236
+ ```
237
+ import type {If, IsEqual} from 'type-fest';
238
+
239
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
240
+
241
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
242
+ //=> 'equal'
243
+
244
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
245
+ //=> 'not equal'
246
+ ```
247
+
248
+ 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:
249
+
250
+ @example
251
+ ```
252
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
253
+
254
+ type HundredZeroes = StringRepeat<'0', 100>;
255
+
256
+ // The following implementation is not tail recursive
257
+ type Includes<S extends string, Char extends string> =
258
+ S extends `${infer First}${infer Rest}`
259
+ ? If<IsEqual<First, Char>,
260
+ 'found',
261
+ Includes<Rest, Char>>
262
+ : 'not found';
263
+
264
+ // Hence, instantiations with long strings will fail
265
+ // @ts-expect-error
266
+ type Fails = Includes<HundredZeroes, '1'>;
267
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268
+ // Error: Type instantiation is excessively deep and possibly infinite.
269
+
270
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
271
+ type IncludesWithoutIf<S extends string, Char extends string> =
272
+ S extends `${infer First}${infer Rest}`
273
+ ? IsEqual<First, Char> extends true
274
+ ? 'found'
275
+ : IncludesWithoutIf<Rest, Char>
276
+ : 'not found';
277
+
278
+ // Now, instantiations with long strings will work
279
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
280
+ //=> 'not found'
281
+ ```
282
+
283
+ @category Type Guard
284
+ @category Utilities
285
+ */
286
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
287
+ /**
288
+ 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.
289
+
290
+ @example
291
+ ```
292
+ import type {Simplify} from 'type-fest';
293
+
294
+ type PositionProps = {
295
+ top: number;
296
+ left: number;
297
+ };
298
+
299
+ type SizeProps = {
300
+ width: number;
301
+ height: number;
302
+ };
303
+
304
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
305
+ type Props = Simplify<PositionProps & SizeProps>;
306
+ ```
307
+
308
+ 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.
309
+
310
+ 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`.
311
+
312
+ @example
313
+ ```
314
+ import type {Simplify} from 'type-fest';
315
+
316
+ interface SomeInterface {
317
+ foo: number;
318
+ bar?: string;
319
+ baz: number | undefined;
320
+ }
321
+
322
+ type SomeType = {
323
+ foo: number;
324
+ bar?: string;
325
+ baz: number | undefined;
326
+ };
327
+
328
+ const literal = {foo: 123, bar: 'hello', baz: 456};
329
+ const someType: SomeType = literal;
330
+ const someInterface: SomeInterface = literal;
331
+
332
+ declare function fn(object: Record<string, unknown>): void;
333
+
334
+ fn(literal); // Good: literal object type is sealed
335
+ fn(someType); // Good: type is sealed
336
+ // @ts-expect-error
337
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
338
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
339
+ ```
340
+
341
+ @link https://github.com/microsoft/TypeScript/issues/15300
342
+ @see {@link SimplifyDeep}
343
+ @category Object
344
+ */
345
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
346
+ /**
347
+ Returns a boolean for whether the two given types are equal.
348
+
349
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
350
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
351
+
352
+ Use-cases:
353
+ - If you want to make a conditional branch based on the result of a comparison of two types.
354
+
355
+ @example
356
+ ```
357
+ import type {IsEqual} from 'type-fest';
358
+
359
+ // This type returns a boolean for whether the given array includes the given item.
360
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
361
+ type Includes<Value extends readonly any[], Item> =
362
+ Value extends readonly [Value[0], ...infer rest]
363
+ ? IsEqual<Value[0], Item> extends true
364
+ ? true
365
+ : Includes<rest, Item>
366
+ : false;
367
+ ```
368
+
369
+ @category Type Guard
370
+ @category Utilities
371
+ */
372
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
373
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
374
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
375
+ /**
376
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
377
+
378
+ This is the counterpart of `PickIndexSignature`.
379
+
380
+ Use-cases:
381
+ - Remove overly permissive signatures from third-party types.
382
+
383
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
384
+
385
+ 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>`.
386
+
387
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
388
+
389
+ ```
390
+ const indexed: Record<string, unknown> = {}; // Allowed
391
+
392
+ // @ts-expect-error
393
+ const keyed: Record<'foo', unknown> = {}; // Error
394
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
395
+ ```
396
+
397
+ 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:
398
+
399
+ ```
400
+ type Indexed = {} extends Record<string, unknown>
401
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
402
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
403
+
404
+ type IndexedResult = Indexed;
405
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
406
+
407
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
408
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
409
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
410
+
411
+ type KeyedResult = Keyed;
412
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
413
+ ```
414
+
415
+ 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`...
416
+
417
+ ```
418
+ type OmitIndexSignature<ObjectType> = {
419
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
420
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
421
+ };
422
+ ```
423
+
424
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
425
+
426
+ ```
427
+ type OmitIndexSignature<ObjectType> = {
428
+ [KeyType in keyof ObjectType
429
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
430
+ as {} extends Record<KeyType, unknown>
431
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
432
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
433
+ ]: ObjectType[KeyType];
434
+ };
435
+ ```
436
+
437
+ 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.
438
+
439
+ @example
440
+ ```
441
+ import type {OmitIndexSignature} from 'type-fest';
442
+
443
+ type Example = {
444
+ // These index signatures will be removed.
445
+ [x: string]: any;
446
+ [x: number]: any;
447
+ [x: symbol]: any;
448
+ [x: `head-${string}`]: string;
449
+ [x: `${string}-tail`]: string;
450
+ [x: `head-${string}-tail`]: string;
451
+ [x: `${bigint}`]: string;
452
+ [x: `embedded-${number}`]: string;
453
+
454
+ // These explicitly defined keys will remain.
455
+ foo: 'bar';
456
+ qux?: 'baz';
457
+ };
458
+
459
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
460
+ //=> {foo: 'bar'; qux?: 'baz'}
461
+ ```
462
+
463
+ @see {@link PickIndexSignature}
464
+ @category Object
465
+ */
466
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
467
+ /**
468
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
469
+
470
+ This is the counterpart of `OmitIndexSignature`.
471
+
472
+ @example
473
+ ```
474
+ import type {PickIndexSignature} from 'type-fest';
475
+
476
+ declare const symbolKey: unique symbol;
477
+
478
+ type Example = {
479
+ // These index signatures will remain.
480
+ [x: string]: unknown;
481
+ [x: number]: unknown;
482
+ [x: symbol]: unknown;
483
+ [x: `head-${string}`]: string;
484
+ [x: `${string}-tail`]: string;
485
+ [x: `head-${string}-tail`]: string;
486
+ [x: `${bigint}`]: string;
487
+ [x: `embedded-${number}`]: string;
488
+
489
+ // These explicitly defined keys will be removed.
490
+ ['kebab-case-key']: string;
491
+ [symbolKey]: string;
492
+ foo: 'bar';
493
+ qux?: 'baz';
494
+ };
495
+
496
+ type ExampleIndexSignature = PickIndexSignature<Example>;
497
+ // {
498
+ // [x: string]: unknown;
499
+ // [x: number]: unknown;
500
+ // [x: symbol]: unknown;
501
+ // [x: `head-${string}`]: string;
502
+ // [x: `${string}-tail`]: string;
503
+ // [x: `head-${string}-tail`]: string;
504
+ // [x: `${bigint}`]: string;
505
+ // [x: `embedded-${number}`]: string;
506
+ // }
507
+ ```
508
+
509
+ @see {@link OmitIndexSignature}
510
+ @category Object
511
+ */
512
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
513
+ // Merges two objects without worrying about index signatures.
514
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
515
+ /**
516
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
517
+
518
+ 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`.
519
+
520
+ @example
521
+ ```
522
+ import type {Merge} from 'type-fest';
523
+
524
+ type Foo = {
525
+ a: string;
526
+ b: number;
527
+ };
528
+
529
+ type Bar = {
530
+ a: number; // Conflicts with Foo['a']
531
+ c: boolean;
532
+ };
533
+
534
+ // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
535
+ type WithIntersection = (Foo & Bar)['a'];
536
+ //=> never
537
+
538
+ // With `Merge`, `a` is cleanly overridden to `number`.
539
+ type WithMerge = Merge<Foo, Bar>['a'];
540
+ //=> number
541
+ ```
542
+
543
+ @example
544
+ ```
545
+ import type {Merge} from 'type-fest';
546
+
547
+ type Foo = {
548
+ [x: string]: unknown;
549
+ [x: number]: unknown;
550
+ foo: string;
551
+ bar: symbol;
552
+ };
553
+
554
+ type Bar = {
555
+ [x: number]: number;
556
+ [x: symbol]: unknown;
557
+ bar: Date;
558
+ baz: boolean;
559
+ };
560
+
561
+ export type FooBar = Merge<Foo, Bar>;
562
+ //=> {
563
+ // [x: string]: unknown;
564
+ // [x: number]: number;
565
+ // [x: symbol]: unknown;
566
+ // foo: string;
567
+ // bar: Date;
568
+ // baz: boolean;
569
+ // }
570
+ ```
571
+
572
+ 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.
573
+
574
+ @see {@link ObjectMerge}
575
+ @category Object
576
+ */
577
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
578
+ ? Source extends unknown // For distributing `Source`
579
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
580
+ : never; // Should never happen
581
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
582
+ /**
583
+ Merges user specified options with default options.
584
+
585
+ @example
586
+ ```
587
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
588
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
589
+ type SpecifiedOptions = {leavesOnly: true};
590
+
591
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
592
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
593
+ ```
594
+
595
+ @example
596
+ ```
597
+ // Complains if default values are not provided for optional options
598
+
599
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
600
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
601
+ type SpecifiedOptions = {};
602
+
603
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
604
+ // ~~~~~~~~~~~~~~~~~~~
605
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
606
+ ```
607
+
608
+ @example
609
+ ```
610
+ // Complains if an option's default type does not conform to the expected type
611
+
612
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
613
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
614
+ type SpecifiedOptions = {};
615
+
616
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
617
+ // ~~~~~~~~~~~~~~~~~~~
618
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
619
+ ```
620
+
621
+ @example
622
+ ```
623
+ // Complains if an option's specified type does not conform to the expected type
624
+
625
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
626
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
627
+ type SpecifiedOptions = {leavesOnly: 'yes'};
628
+
629
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
630
+ // ~~~~~~~~~~~~~~~~
631
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
632
+ ```
633
+ */
634
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends (infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
635
+ ) ? Result : never;
636
+ type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key]; }>>>;
637
+ /**
638
+ Filter out keys from an object.
639
+
640
+ Returns `never` if `Exclude` is strictly equal to `Key`.
641
+ Returns `never` if `Key` extends `Exclude`.
642
+ Returns `Key` otherwise.
643
+
644
+ @example
645
+ ```
646
+ type Filtered = Filter<'foo', 'foo'>;
647
+ //=> never
648
+ ```
649
+
650
+ @example
651
+ ```
652
+ type Filtered = Filter<'bar', string>;
653
+ //=> never
654
+ ```
655
+
656
+ @example
657
+ ```
658
+ type Filtered = Filter<'bar', 'foo'>;
659
+ //=> 'bar'
660
+ ```
661
+
662
+ @see {Except}
663
+ */
664
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
665
+ type ExceptOptions = {
666
+ /**
667
+ Disallow assigning non-specified properties.
668
+
669
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
670
+
671
+ @default false
672
+ */
673
+ requireExactProps?: boolean;
674
+ };
675
+ type DefaultExceptOptions = {
676
+ requireExactProps: false;
677
+ };
678
+ /**
679
+ Create a type from an object type without certain keys.
680
+
681
+ We recommend setting the `requireExactProps` option to `true`.
682
+
683
+ 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.
684
+
685
+ 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)).
686
+
687
+ @example
688
+ ```
689
+ import type {Except} from 'type-fest';
690
+
691
+ type Foo = {
692
+ a: number;
693
+ b: string;
694
+ };
695
+
696
+ type FooWithoutA = Except<Foo, 'a'>;
697
+ //=> {b: string}
698
+
699
+ // @ts-expect-error
700
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
701
+ // errors: 'a' does not exist in type '{ b: string; }'
702
+
703
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
704
+ //=> {a: number} & Partial<Record<'b', never>>
705
+
706
+ // @ts-expect-error
707
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
708
+ // errors at 'b': Type 'string' is not assignable to type 'undefined'.
709
+
710
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
711
+
712
+ // Consider the following example:
713
+
714
+ type UserData = {
715
+ [metadata: string]: string;
716
+ email: string;
717
+ name: string;
718
+ role: 'admin' | 'user';
719
+ };
720
+
721
+ // `Omit` clearly doesn't behave as expected in this case:
722
+ type PostPayload = Omit<UserData, 'email'>;
723
+ //=> {[x: string]: string; [x: number]: string}
724
+
725
+ // In situations like this, `Except` works better.
726
+ // It simply removes the `email` key while preserving all the other keys.
727
+ type PostPayloadFixed = Except<UserData, 'email'>;
728
+ //=> {[x: string]: string; name: string; role: 'admin' | 'user'}
729
+ ```
730
+
731
+ @category Object
732
+ */
733
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
734
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
735
+ declare namespace TsConfigJson {
736
+ namespace CompilerOptions {
737
+ type JSX = 'preserve' | 'react' | 'react-jsx' | 'react-jsxdev' | 'react-native';
738
+ type Module = 'CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ES2022' | 'ESNext' | 'Node16' | 'Node18' | 'Node20' | 'NodeNext' | 'Preserve' | 'None' |
739
+ // Lowercase alternatives
740
+ 'commonjs' | 'amd' | 'system' | 'umd' | 'es6' | 'es2015' | 'es2020' | 'es2022' | 'esnext' | 'node16' | 'node18' | 'node20' | 'nodenext' | 'preserve' | 'none';
741
+ type NewLine = 'CRLF' | 'LF' |
742
+ // Lowercase alternatives
743
+ 'crlf' | 'lf';
744
+ type Target = 'ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ES2024' | 'ES2025' | 'ESNext' |
745
+ // Lowercase alternatives
746
+ 'es3' | 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023' | 'es2024' | 'es2025' | 'esnext';
747
+ type Lib = 'ES5' | 'ES6' | 'ES7' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.ArrayBuffer' | 'ES2017.Date' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Intl' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Date' | 'ES2020.Intl' | 'ES2020.Number' | 'ES2020.Promise' | 'ES2020.SharedMemory' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ES2021' | 'ES2021.Intl' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.RegExp' | 'ES2022.SharedMemory' | 'ES2022.String' | 'ES2023' | 'ES2023.Array' | 'ES2023.Collection' | 'ES2023.Intl' | 'ES2024' | 'ES2024.ArrayBuffer' | 'ES2024.Collection' | 'ES2024.Object' | 'ES2024.Promise' | 'ES2024.Regexp' | 'ES2024.SharedMemory' | 'ES2024.String' | 'ES2025' | 'ES2025.Collection' | 'ES2025.Float16' | 'ES2025.Intl' | 'ES2025.Iterator' | 'ES2025.Promise' | 'ES2025.RegExp' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable' | 'ESNext.Error' | 'ESNext.Float16' | 'ESNext.Intl' | 'ESNext.Iterator' | 'ESNext.Object' | 'ESNext.Promise' | 'ESNext.Regexp' | 'ESNext.String' | 'ESNext.Symbol' | 'ESNext.Temporal' | 'ESNext.WeakRef' | 'DOM' | 'DOM.AsyncIterable' | 'DOM.Iterable' | 'Decorators' | 'Decorators.Legacy' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'WebWorker.Iterable' |
748
+ // Lowercase alternatives
749
+ 'es5' | 'es6' | 'es7' | 'es2015' | 'es2015.collection' | 'es2015.core' | 'es2015.generator' | 'es2015.iterable' | 'es2015.promise' | 'es2015.proxy' | 'es2015.reflect' | 'es2015.symbol.wellknown' | 'es2015.symbol' | 'es2016' | 'es2016.array.include' | 'es2017' | 'es2017.arraybuffer' | 'es2017.date' | 'es2017.intl' | 'es2017.object' | 'es2017.sharedmemory' | 'es2017.string' | 'es2017.typedarrays' | 'es2018' | 'es2018.asyncgenerator' | 'es2018.asynciterable' | 'es2018.intl' | 'es2018.promise' | 'es2018.regexp' | 'es2019' | 'es2019.array' | 'es2019.intl' | 'es2019.object' | 'es2019.string' | 'es2019.symbol' | 'es2020' | 'es2020.bigint' | 'es2020.date' | 'es2020.intl' | 'es2020.number' | 'es2020.promise' | 'es2020.sharedmemory' | 'es2020.string' | 'es2020.symbol.wellknown' | 'es2021' | 'es2021.intl' | 'es2021.promise' | 'es2021.string' | 'es2021.weakref' | 'es2022' | 'es2022.array' | 'es2022.error' | 'es2022.intl' | 'es2022.object' | 'es2022.regexp' | 'es2022.sharedmemory' | 'es2022.string' | 'es2023' | 'es2023.array' | 'es2023.collection' | 'es2023.intl' | 'es2024' | 'es2024.arraybuffer' | 'es2024.collection' | 'es2024.object' | 'es2024.promise' | 'es2024.regexp' | 'es2024.sharedmemory' | 'es2024.string' | 'es2025' | 'es2025.collection' | 'es2025.float16' | 'es2025.intl' | 'es2025.iterator' | 'es2025.promise' | 'es2025.regexp' | 'esnext' | 'esnext.array' | 'esnext.asynciterable' | 'esnext.bigint' | 'esnext.collection' | 'esnext.decorators' | 'esnext.disposable' | 'esnext.error' | 'esnext.float16' | 'esnext.intl' | 'esnext.iterator' | 'esnext.object' | 'esnext.promise' | 'esnext.regexp' | 'esnext.string' | 'esnext.symbol' | 'esnext.temporal' | 'esnext.weakref' | 'dom' | 'dom.asynciterable' | 'dom.iterable' | 'decorators' | 'decorators.legacy' | 'scripthost' | 'webworker' | 'webworker.asynciterable' | 'webworker.importscripts' | 'webworker.iterable';
750
+ type Plugin = {
751
+ /**
752
+ Plugin name.
753
+ */
754
+ name: string;
755
+ };
756
+ type ImportsNotUsedAsValues = 'remove' | 'preserve' | 'error';
757
+ type FallbackPolling = 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'fixedInterval' | 'priorityInterval' | 'dynamicPriority' | 'fixedChunkSize';
758
+ type WatchDirectory = 'useFsEvents' | 'fixedPollingInterval' | 'dynamicPriorityPolling' | 'fixedChunkSizePolling';
759
+ type WatchFile = 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'useFsEvents' | 'useFsEventsOnParentDirectory' | 'fixedChunkSizePolling';
760
+ type ModuleResolution = 'classic' | 'node' | 'node10' | 'node16' | 'nodenext' | 'bundler' |
761
+ // Pascal-cased alternatives
762
+ 'Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler';
763
+ type ModuleDetection = 'auto' | 'legacy' | 'force';
764
+ type IgnoreDeprecations = '5.0' | '6.0';
765
+ }
766
+ type CompilerOptions = {
767
+ /**
768
+ The character set of the input files.
769
+
770
+ @default 'utf8'
771
+ @deprecated This option will be removed in TypeScript 5.5.
772
+ */
773
+ charset?: string;
774
+ /**
775
+ Enables building for project references.
776
+
777
+ @default true
778
+ */
779
+ composite?: boolean;
780
+ /**
781
+ Generates corresponding d.ts files.
782
+
783
+ @default false
784
+ */
785
+ declaration?: boolean;
786
+ /**
787
+ Specify output directory for generated declaration files.
788
+ */
789
+ declarationDir?: string;
790
+ /**
791
+ Show diagnostic information.
792
+
793
+ @default false
794
+ */
795
+ diagnostics?: boolean;
796
+ /**
797
+ Reduce the number of projects loaded automatically by TypeScript.
798
+
799
+ @default false
800
+ */
801
+ disableReferencedProjectLoad?: boolean;
802
+ /**
803
+ Enforces using indexed accessors for keys declared using an indexed type.
804
+
805
+ @default false
806
+ */
807
+ noPropertyAccessFromIndexSignature?: boolean;
808
+ /**
809
+ Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
810
+
811
+ @default false
812
+ */
813
+ emitBOM?: boolean;
814
+ /**
815
+ Only emit `.d.ts` declaration files.
816
+
817
+ @default false
818
+ */
819
+ emitDeclarationOnly?: boolean;
820
+ /**
821
+ Differentiate between undefined and not present when type checking.
822
+
823
+ @default false
824
+ */
825
+ exactOptionalPropertyTypes?: boolean;
826
+ /**
827
+ Enable incremental compilation.
828
+
829
+ @default `composite`
830
+ */
831
+ incremental?: boolean;
832
+ /**
833
+ Specify file to store incremental compilation information.
834
+
835
+ @default '.tsbuildinfo'
836
+ */
837
+ tsBuildInfoFile?: string;
838
+ /**
839
+ Emit a single file with source maps instead of having a separate file.
840
+
841
+ @default false
842
+ */
843
+ inlineSourceMap?: boolean;
844
+ /**
845
+ Emit the source alongside the sourcemaps within a single file.
846
+
847
+ Requires `--inlineSourceMap` to be set.
848
+
849
+ @default false
850
+ */
851
+ inlineSources?: boolean;
852
+ /**
853
+ Specify what JSX code is generated.
854
+
855
+ @default 'preserve'
856
+ */
857
+ jsx?: CompilerOptions.JSX;
858
+ /**
859
+ Specifies the object invoked for `createElement` and `__spread` when targeting `'react'` JSX emit.
860
+
861
+ @default 'React'
862
+ */
863
+ reactNamespace?: string;
864
+ /**
865
+ Specify the JSX factory function to use when targeting React JSX emit, e.g. `React.createElement` or `h`.
866
+
867
+ @default 'React.createElement'
868
+ */
869
+ jsxFactory?: string;
870
+ /**
871
+ Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
872
+
873
+ @default 'React.Fragment'
874
+ */
875
+ jsxFragmentFactory?: string;
876
+ /**
877
+ Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.
878
+
879
+ @default 'react'
880
+ */
881
+ jsxImportSource?: string;
882
+ /**
883
+ Print names of files part of the compilation.
884
+
885
+ @default false
886
+ */
887
+ listFiles?: boolean;
888
+ /**
889
+ Specifies the location where debugger should locate map files instead of generated locations.
890
+ */
891
+ mapRoot?: string;
892
+ /**
893
+ Specify module code generation: 'None', 'CommonJS', 'AMD', 'System', 'UMD', 'ES6', 'ES2015' or 'ESNext'. Only 'AMD' and 'System' can be used in conjunction with `--outFile`. 'ES6' and 'ES2015' values may be used when targeting 'ES5' or lower.
894
+
895
+ Default: `'ESNext'` since TypeScript 6.0, `['ES3', 'ES5'].includes(target) ? 'CommonJS' : 'ES6'` before.
896
+ */
897
+ module?: CompilerOptions.Module;
898
+ /**
899
+ Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6).
900
+
901
+ @default ['AMD', 'System', 'ES6'].includes(module) ? 'classic' : 'node'
902
+ */
903
+ moduleResolution?: CompilerOptions.ModuleResolution;
904
+ /**
905
+ Specifies the end of line sequence to be used when emitting files: 'crlf' (Windows) or 'lf' (Unix).
906
+
907
+ @default 'LF'
908
+ */
909
+ newLine?: CompilerOptions.NewLine;
910
+ /**
911
+ Disable full type checking (only critical parse and emit errors will be reported).
912
+
913
+ @default false
914
+ */
915
+ noCheck?: boolean;
916
+ /**
917
+ Do not emit output.
918
+
919
+ @default false
920
+ */
921
+ noEmit?: boolean;
922
+ /**
923
+ Do not generate custom helper functions like `__extends` in compiled output.
924
+
925
+ @default false
926
+ */
927
+ noEmitHelpers?: boolean;
928
+ /**
929
+ Do not emit outputs if any type checking errors were reported.
930
+
931
+ @default false
932
+ */
933
+ noEmitOnError?: boolean;
934
+ /**
935
+ Warn on expressions and declarations with an implied 'any' type.
936
+
937
+ @default false
938
+ */
939
+ noImplicitAny?: boolean;
940
+ /**
941
+ Raise error on 'this' expressions with an implied any type.
942
+
943
+ @default false
944
+ */
945
+ noImplicitThis?: boolean;
946
+ /**
947
+ Report errors on unused locals.
948
+
949
+ @default false
950
+ */
951
+ noUnusedLocals?: boolean;
952
+ /**
953
+ Report errors on unused parameters.
954
+
955
+ @default false
956
+ */
957
+ noUnusedParameters?: boolean;
958
+ /**
959
+ Do not include the default library file (lib.d.ts).
960
+
961
+ @default false
962
+ */
963
+ noLib?: boolean;
964
+ /**
965
+ Do not add triple-slash references or module import targets to the list of compiled files.
966
+
967
+ @default false
968
+ */
969
+ noResolve?: boolean;
970
+ /**
971
+ Disable strict checking of generic signatures in function types.
972
+
973
+ @default false
974
+ @deprecated This option will be removed in TypeScript 5.5.
975
+ */
976
+ noStrictGenericChecks?: boolean;
977
+ /**
978
+ @deprecated use `skipLibCheck` instead.
979
+ */
980
+ skipDefaultLibCheck?: boolean;
981
+ /**
982
+ Skip type checking of declaration files.
983
+
984
+ @default false
985
+ */
986
+ skipLibCheck?: boolean;
987
+ /**
988
+ Enforce stable type ordering.
989
+
990
+ @default false
991
+ */
992
+ stableTypeOrdering?: boolean;
993
+ /**
994
+ Concatenate and emit output to single file.
995
+
996
+ @deprecated since TypeScript 6.0.
997
+ */
998
+ outFile?: string;
999
+ /**
1000
+ Redirect output structure to the directory.
1001
+ */
1002
+ outDir?: string;
1003
+ /**
1004
+ Do not erase const enum declarations in generated code.
1005
+
1006
+ @default false
1007
+ */
1008
+ preserveConstEnums?: boolean;
1009
+ /**
1010
+ Do not resolve symlinks to their real path; treat a symlinked file like a real one.
1011
+
1012
+ @default false
1013
+ */
1014
+ preserveSymlinks?: boolean;
1015
+ /**
1016
+ Keep outdated console output in watch mode instead of clearing the screen.
1017
+
1018
+ @default false
1019
+ */
1020
+ preserveWatchOutput?: boolean;
1021
+ /**
1022
+ Stylize errors and messages using color and context (experimental).
1023
+
1024
+ @default true // Unless piping to another program or redirecting output to a file.
1025
+ */
1026
+ pretty?: boolean;
1027
+ /**
1028
+ Do not emit comments to output.
1029
+
1030
+ @default false
1031
+ */
1032
+ removeComments?: boolean;
1033
+ /**
1034
+ Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files.
1035
+
1036
+ @default false
1037
+ */
1038
+ rewriteRelativeImportExtensions?: boolean;
1039
+ /**
1040
+ Specifies the root directory of input files.
1041
+
1042
+ Use to control the output directory structure with `--outDir`.
1043
+ */
1044
+ rootDir?: string;
1045
+ /**
1046
+ Unconditionally emit imports for unresolved files.
1047
+
1048
+ @default false
1049
+ */
1050
+ isolatedModules?: boolean;
1051
+ /**
1052
+ Require sufficient annotation on exports so other tools can trivially generate declaration files.
1053
+
1054
+ @default false
1055
+ */
1056
+ isolatedDeclarations?: boolean;
1057
+ /**
1058
+ Generates corresponding '.map' file.
1059
+
1060
+ @default false
1061
+ */
1062
+ sourceMap?: boolean;
1063
+ /**
1064
+ Specifies the location where debugger should locate TypeScript files instead of source locations.
1065
+ */
1066
+ sourceRoot?: string;
1067
+ /**
1068
+ Suppress excess property checks for object literals.
1069
+
1070
+ @default false
1071
+ @deprecated This option will be removed in TypeScript 5.5.
1072
+ */
1073
+ suppressExcessPropertyErrors?: boolean;
1074
+ /**
1075
+ Suppress noImplicitAny errors for indexing objects lacking index signatures.
1076
+
1077
+ @default false
1078
+ @deprecated This option will be removed in TypeScript 5.5.
1079
+ */
1080
+ suppressImplicitAnyIndexErrors?: boolean;
1081
+
1082
+ /**
1083
+ Specify ECMAScript target version.
1084
+
1085
+ Default: Current-year ES version since TypeScript 6.0, `'es3'` before.
1086
+ */
1087
+ target?: CompilerOptions.Target;
1088
+ /**
1089
+ Default catch clause variables as `unknown` instead of `any`.
1090
+
1091
+ @default false
1092
+ */
1093
+ useUnknownInCatchVariables?: boolean;
1094
+ /**
1095
+ Watch input files.
1096
+
1097
+ @default false
1098
+ @deprecated Use watchOptions instead.
1099
+ */
1100
+ watch?: boolean;
1101
+ /**
1102
+ Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
1103
+
1104
+ @deprecated Use watchOptions.fallbackPolling instead.
1105
+ */
1106
+ fallbackPolling?: CompilerOptions.FallbackPolling;
1107
+ /**
1108
+ Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
1109
+
1110
+ @default 'useFsEvents'
1111
+ @deprecated Use watchOptions.watchDirectory instead.
1112
+ */
1113
+ watchDirectory?: CompilerOptions.WatchDirectory;
1114
+ /**
1115
+ Specify the strategy for watching individual files.
1116
+
1117
+ @default 'useFsEvents'
1118
+ @deprecated Use watchOptions.watchFile instead.
1119
+ */
1120
+ watchFile?: CompilerOptions.WatchFile;
1121
+ /**
1122
+ Enables experimental support for ES7 decorators.
1123
+
1124
+ @default false
1125
+ */
1126
+ experimentalDecorators?: boolean;
1127
+ /**
1128
+ Emit design-type metadata for decorated declarations in source.
1129
+
1130
+ @default false
1131
+ */
1132
+ emitDecoratorMetadata?: boolean;
1133
+ /**
1134
+ Do not report errors on unused labels.
1135
+
1136
+ @default false
1137
+ */
1138
+ allowUnusedLabels?: boolean;
1139
+ /**
1140
+ Report error when not all code paths in function return a value.
1141
+
1142
+ @default false
1143
+ */
1144
+ noImplicitReturns?: boolean;
1145
+ /**
1146
+ Add `undefined` to a type when accessed using an index.
1147
+
1148
+ @default false
1149
+ */
1150
+ noUncheckedIndexedAccess?: boolean;
1151
+ /**
1152
+ Report error if failed to find a source file for a side effect import.
1153
+
1154
+ Default: `true` since TypeScript 6.0, `false` before.
1155
+ */
1156
+ noUncheckedSideEffectImports?: boolean;
1157
+ /**
1158
+ Report errors for fallthrough cases in switch statement.
1159
+
1160
+ @default false
1161
+ */
1162
+ noFallthroughCasesInSwitch?: boolean;
1163
+ /**
1164
+ Ensure overriding members in derived classes are marked with an override modifier.
1165
+
1166
+ @default false
1167
+ */
1168
+ noImplicitOverride?: boolean;
1169
+ /**
1170
+ Do not report errors on unreachable code.
1171
+
1172
+ @default false
1173
+ */
1174
+ allowUnreachableCode?: boolean;
1175
+ /**
1176
+ Disallow inconsistently-cased references to the same file.
1177
+
1178
+ @default true
1179
+ */
1180
+ forceConsistentCasingInFileNames?: boolean;
1181
+ /**
1182
+ Emit a v8 CPU profile of the compiler run for debugging.
1183
+
1184
+ @default 'profile.cpuprofile'
1185
+ */
1186
+ generateCpuProfile?: string;
1187
+ /**
1188
+ Generates an event trace and a list of types.
1189
+ */
1190
+ generateTrace?: boolean;
1191
+ /**
1192
+ Base directory to resolve non-relative module names.
1193
+
1194
+ @deprecated since TypeScript 6.0.
1195
+ */
1196
+ baseUrl?: string;
1197
+ /**
1198
+ Specify path mapping to be computed relative to baseUrl option.
1199
+ */
1200
+ paths?: Record<string, string[]>;
1201
+ /**
1202
+ List of TypeScript language server plugins to load.
1203
+ */
1204
+ plugins?: CompilerOptions.Plugin[];
1205
+ /**
1206
+ Specify list of root directories to be used when resolving modules.
1207
+ */
1208
+ rootDirs?: string[];
1209
+ /**
1210
+ Specify list of directories for type definition files to be included.
1211
+ */
1212
+ typeRoots?: string[];
1213
+ /**
1214
+ Type declaration files to be included in compilation.
1215
+ */
1216
+ types?: string[];
1217
+ /**
1218
+ Enable tracing of the name resolution process.
1219
+
1220
+ @default false
1221
+ */
1222
+ traceResolution?: boolean;
1223
+ /**
1224
+ Allow javascript files to be compiled.
1225
+
1226
+ @default false
1227
+ */
1228
+ allowJs?: boolean;
1229
+ /**
1230
+ Do not truncate error messages.
1231
+
1232
+ @default false
1233
+ */
1234
+ noErrorTruncation?: boolean;
1235
+ /**
1236
+ Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
1237
+
1238
+ @default module === 'system' || esModuleInterop
1239
+ */
1240
+ allowSyntheticDefaultImports?: boolean;
1241
+ /**
1242
+ Do not emit `'use strict'` directives in module output.
1243
+
1244
+ @default false
1245
+ @deprecated This option will be removed in TypeScript 5.5.
1246
+ */
1247
+ noImplicitUseStrict?: boolean;
1248
+ /**
1249
+ Enable to list all emitted files.
1250
+
1251
+ @default false
1252
+ */
1253
+ listEmittedFiles?: boolean;
1254
+ /**
1255
+ Disable size limit for JavaScript project.
1256
+
1257
+ @default false
1258
+ */
1259
+ disableSizeLimit?: boolean;
1260
+ /**
1261
+ List of library files to be included in the compilation.
1262
+ */
1263
+ lib?: CompilerOptions.Lib[];
1264
+ /**
1265
+ Enable strict null checks.
1266
+
1267
+ @default false
1268
+ */
1269
+ strictNullChecks?: boolean;
1270
+ /**
1271
+ The maximum dependency depth to search under `node_modules` and load JavaScript files. Only applicable with `--allowJs`.
1272
+
1273
+ @default 0
1274
+ */
1275
+ maxNodeModuleJsDepth?: number;
1276
+ /**
1277
+ Import emit helpers (e.g. `__extends`, `__rest`, etc..) from tslib.
1278
+
1279
+ @default false
1280
+ */
1281
+ importHelpers?: boolean;
1282
+ /**
1283
+ Specify emit/checking behavior for imports that are only used for types.
1284
+
1285
+ @default 'remove'
1286
+ @deprecated Use `verbatimModuleSyntax` instead.
1287
+ */
1288
+ importsNotUsedAsValues?: CompilerOptions.ImportsNotUsedAsValues;
1289
+ /**
1290
+ Parse in strict mode and emit `'use strict'` for each source file.
1291
+
1292
+ @default false
1293
+ */
1294
+ alwaysStrict?: boolean;
1295
+ /**
1296
+ Enable all strict type checking options.
1297
+
1298
+ Default: `true` since TypeScript 6.0, `false` before.
1299
+ */
1300
+ strict?: boolean;
1301
+ /**
1302
+ Enable stricter checking of of the `bind`, `call`, and `apply` methods on functions.
1303
+
1304
+ @default false
1305
+ */
1306
+ strictBindCallApply?: boolean;
1307
+ /**
1308
+ Provide full support for iterables in `for-of`, spread, and destructuring when targeting `ES5` or `ES3`.
1309
+
1310
+ @default false
1311
+ @deprecated since TypeScript 6.0.
1312
+ */
1313
+ downlevelIteration?: boolean;
1314
+ /**
1315
+ Report errors in `.js` files.
1316
+
1317
+ @default false
1318
+ */
1319
+ checkJs?: boolean;
1320
+ /**
1321
+ Built-in iterators are instantiated with a `TReturn` type of undefined instead of `any`.
1322
+
1323
+ @default false
1324
+ */
1325
+ strictBuiltinIteratorReturn?: boolean;
1326
+ /**
1327
+ Disable bivariant parameter checking for function types.
1328
+
1329
+ @default false
1330
+ */
1331
+ strictFunctionTypes?: boolean;
1332
+ /**
1333
+ Ensure non-undefined class properties are initialized in the constructor.
1334
+
1335
+ @default false
1336
+ */
1337
+ strictPropertyInitialization?: boolean;
1338
+ /**
1339
+ Emit `__importStar` and `__importDefault` helpers for runtime Babel ecosystem compatibility and enable `--allowSyntheticDefaultImports` for typesystem compatibility.
1340
+
1341
+ @default false
1342
+ */
1343
+ esModuleInterop?: boolean;
1344
+ /**
1345
+ Allow accessing UMD globals from modules.
1346
+
1347
+ @default false
1348
+ */
1349
+ allowUmdGlobalAccess?: boolean;
1350
+ /**
1351
+ Resolve `keyof` to string valued property names only (no numbers or symbols).
1352
+
1353
+ @default false
1354
+ @deprecated This option will be removed in TypeScript 5.5.
1355
+ */
1356
+ keyofStringsOnly?: boolean;
1357
+ /**
1358
+ Emit ECMAScript standard class fields.
1359
+
1360
+ @default false
1361
+ */
1362
+ useDefineForClassFields?: boolean;
1363
+ /**
1364
+ Generates a sourcemap for each corresponding `.d.ts` file.
1365
+
1366
+ @default false
1367
+ */
1368
+ declarationMap?: boolean;
1369
+ /**
1370
+ Include modules imported with `.json` extension.
1371
+
1372
+ @default false
1373
+ */
1374
+ resolveJsonModule?: boolean;
1375
+ /**
1376
+ Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.
1377
+
1378
+ @default false
1379
+ */
1380
+ assumeChangesOnlyAffectDirectDependencies?: boolean;
1381
+ /**
1382
+ Output more detailed compiler performance information after building.
1383
+
1384
+ @default false
1385
+ */
1386
+ extendedDiagnostics?: boolean;
1387
+ /**
1388
+ Print names of files that are part of the compilation and then stop processing.
1389
+
1390
+ @default false
1391
+ */
1392
+ listFilesOnly?: boolean;
1393
+ /**
1394
+ Disable preferring source files instead of declaration files when referencing composite projects.
1395
+
1396
+ @default true if composite, false otherwise
1397
+ */
1398
+ disableSourceOfProjectReferenceRedirect?: boolean;
1399
+ /**
1400
+ Opt a project out of multi-project reference checking when editing.
1401
+
1402
+ @default false
1403
+ */
1404
+ disableSolutionSearching?: boolean;
1405
+ /**
1406
+ Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
1407
+
1408
+ @default false
1409
+ */
1410
+ explainFiles?: boolean;
1411
+ /**
1412
+ Preserve unused imported values in the JavaScript output that would otherwise be removed.
1413
+
1414
+ @default true
1415
+ @deprecated Use `verbatimModuleSyntax` instead.
1416
+ */
1417
+ preserveValueImports?: boolean;
1418
+ /**
1419
+ List of file name suffixes to search when resolving a module.
1420
+ */
1421
+ moduleSuffixes?: string[];
1422
+ /**
1423
+ Control what method is used to detect module-format JS files.
1424
+
1425
+ @default 'auto'
1426
+ */
1427
+ moduleDetection?: CompilerOptions.ModuleDetection;
1428
+ /**
1429
+ Allows TypeScript files to import each other with a TypeScript-specific extension like .ts, .mts, or .tsx.
1430
+
1431
+ @default false
1432
+ */
1433
+ allowImportingTsExtensions?: boolean;
1434
+ /**
1435
+ Forces TypeScript to consult the exports field of package.json files if it ever reads from a package in node_modules.
1436
+
1437
+ @default false
1438
+ */
1439
+ resolvePackageJsonExports?: boolean;
1440
+ /**
1441
+ Forces TypeScript to consult the imports field of package.json files when performing a lookup that starts with # from a file whose ancestor directory contains a package.json.
1442
+
1443
+ @default false
1444
+ */
1445
+ resolvePackageJsonImports?: boolean;
1446
+ /**
1447
+ Suppress errors for file formats that TypeScript does not understand.
1448
+
1449
+ @default false
1450
+ */
1451
+ allowArbitraryExtensions?: boolean;
1452
+ /**
1453
+ List of additional conditions that should succeed when TypeScript resolves from package.json.
1454
+ */
1455
+ customConditions?: string[];
1456
+ /**
1457
+ Anything that uses the type modifier is dropped entirely.
1458
+
1459
+ @default false
1460
+ */
1461
+ verbatimModuleSyntax?: boolean;
1462
+ /**
1463
+ Suppress deprecation warnings
1464
+ */
1465
+ ignoreDeprecations?: CompilerOptions.IgnoreDeprecations;
1466
+ /**
1467
+ Do not allow runtime constructs that are not part of ECMAScript.
1468
+
1469
+ @default false
1470
+ */
1471
+ erasableSyntaxOnly?: boolean;
1472
+ /**
1473
+ Enable lib replacement.
1474
+
1475
+ Default: `false` since TypeScript 6.0, `true` before.
1476
+ */
1477
+ libReplacement?: boolean;
1478
+ };
1479
+ namespace WatchOptions {
1480
+ type WatchFileKind = 'FixedPollingInterval' | 'PriorityPollingInterval' | 'DynamicPriorityPolling' | 'FixedChunkSizePolling' | 'UseFsEvents' | 'UseFsEventsOnParentDirectory';
1481
+ type WatchDirectoryKind = 'UseFsEvents' | 'FixedPollingInterval' | 'DynamicPriorityPolling' | 'FixedChunkSizePolling';
1482
+ type PollingWatchKind = 'FixedInterval' | 'PriorityInterval' | 'DynamicPriority' | 'FixedChunkSize';
1483
+ }
1484
+ type WatchOptions = {
1485
+ /**
1486
+ Specify the strategy for watching individual files.
1487
+
1488
+ @default 'UseFsEvents'
1489
+ */
1490
+ watchFile?: WatchOptions.WatchFileKind | Lowercase<WatchOptions.WatchFileKind>;
1491
+ /**
1492
+ Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
1493
+
1494
+ @default 'UseFsEvents'
1495
+ */
1496
+ watchDirectory?: WatchOptions.WatchDirectoryKind | Lowercase<WatchOptions.WatchDirectoryKind>;
1497
+ /**
1498
+ Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
1499
+ */
1500
+ fallbackPolling?: WatchOptions.PollingWatchKind | Lowercase<WatchOptions.PollingWatchKind>;
1501
+ /**
1502
+ Enable synchronous updates on directory watchers for platforms that don't support recursive watching natively.
1503
+ */
1504
+ synchronousWatchDirectory?: boolean;
1505
+ /**
1506
+ Specifies a list of directories to exclude from watch.
1507
+ */
1508
+ excludeDirectories?: string[];
1509
+ /**
1510
+ Specifies a list of files to exclude from watch.
1511
+ */
1512
+ excludeFiles?: string[];
1513
+ };
1514
+ /**
1515
+ Auto type (.d.ts) acquisition options for this project.
1516
+ */
1517
+ type TypeAcquisition = {
1518
+ /**
1519
+ Enable auto type acquisition.
1520
+ */
1521
+ enable?: boolean;
1522
+ /**
1523
+ Specifies a list of type declarations to be included in auto type acquisition. For example, `['jquery', 'lodash']`.
1524
+ */
1525
+ include?: string[];
1526
+ /**
1527
+ Specifies a list of type declarations to be excluded from auto type acquisition. For example, `['jquery', 'lodash']`.
1528
+ */
1529
+ exclude?: string[];
1530
+ /**
1531
+ Disable infering what types should be added based on filenames in a project.
1532
+ */
1533
+ disableFilenameBasedTypeAcquisition?: boolean;
1534
+ };
1535
+ type References = {
1536
+ /**
1537
+ A normalized path on disk.
1538
+ */
1539
+ path: string;
1540
+ /**
1541
+ The path as the user originally wrote it.
1542
+ */
1543
+ originalPath?: string;
1544
+ /**
1545
+ True if the output of this reference should be prepended to the output of this project.
1546
+
1547
+ Only valid for `--outFile` compilations.
1548
+ @deprecated This option will be removed in TypeScript 5.5.
1549
+ */
1550
+ prepend?: boolean;
1551
+ /**
1552
+ True if it is intended that this reference form a circularity.
1553
+ */
1554
+ circular?: boolean;
1555
+ };
1556
+ }
1557
+ /**
1558
+ Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
1559
+
1560
+ @category File
1561
+ */
1562
+ type TsConfigJson = {
1563
+ /**
1564
+ Instructs the TypeScript compiler how to compile `.ts` files.
1565
+ */
1566
+ compilerOptions?: TsConfigJson.CompilerOptions;
1567
+ /**
1568
+ Instructs the TypeScript compiler how to watch files.
1569
+ */
1570
+ watchOptions?: TsConfigJson.WatchOptions;
1571
+ /**
1572
+ Auto type (.d.ts) acquisition options for this project.
1573
+ */
1574
+ typeAcquisition?: TsConfigJson.TypeAcquisition;
1575
+ /**
1576
+ Enable Compile-on-Save for this project.
1577
+ */
1578
+ compileOnSave?: boolean;
1579
+ /**
1580
+ Path to base configuration file to inherit from.
1581
+ */
1582
+ extends?: string | string[];
1583
+ /**
1584
+ If no `files` or `include` property is present in a `tsconfig.json`, the compiler defaults to including all files in the containing directory and subdirectories except those specified by `exclude`. When a `files` property is specified, only those files and those specified by `include` are included.
1585
+ */
1586
+ files?: string[];
1587
+ /**
1588
+ Specifies a list of files to be excluded from compilation. The `exclude` property only affects the files included via the `include` property and not the `files` property.
1589
+
1590
+ Glob patterns require TypeScript version 2.0 or later.
1591
+ */
1592
+ exclude?: string[];
1593
+ /**
1594
+ Specifies a list of glob patterns that match files to be included in compilation.
1595
+
1596
+ If no `files` or `include` property is present in a `tsconfig.json`, the compiler defaults to including all files in the containing directory and subdirectories except those specified by `exclude`.
1597
+ */
1598
+ include?: string[];
1599
+ /**
1600
+ Referenced projects.
1601
+ */
1602
+ references?: TsConfigJson.References[];
1603
+ };
4
1604
  type TsConfigJsonResolved = Except<TsConfigJson, "extends">;
5
1605
  type Options$1 = {
6
1606
  /**
@@ -107,4 +1707,4 @@ declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteTsConfigOpt
107
1707
  * @param options Optional. Write options plus the target directory (`cwd`), `fileName`, and `typescriptMajor`.
108
1708
  */
109
1709
  declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteTsConfigOptions) => void;
110
- export { type Options as FindTsConfigOptions, type Options$1 as ReadTsConfigOptions, type TsConfigJsonResolved, type TsConfigResult, type WriteTsConfigOptions, configDirectoryPlaceholder, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTsConfig, writeTsConfigSync };
1710
+ export { type Options as FindTsConfigOptions, type Options$1 as ReadTsConfigOptions, type TsConfigJson, type TsConfigJsonResolved, type TsConfigResult, type WriteTsConfigOptions, configDirectoryPlaceholder, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTsConfig, writeTsConfigSync };