@visulima/tsconfig 1.2.0 → 2.0.0

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