type-fest 3.3.0 → 3.5.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/index.d.ts CHANGED
@@ -74,6 +74,7 @@ export type {RequiredKeysOf} from './source/required-keys-of';
74
74
  export type {HasRequiredKeys} from './source/has-required-keys';
75
75
  export type {Spread} from './source/spread';
76
76
  export type {TupleToUnion} from './source/tuple-to-union';
77
+ export type {IsEqual} from './source/is-equal';
77
78
 
78
79
  // Template literal types
79
80
  export type {CamelCase} from './source/camel-case';
@@ -101,5 +102,6 @@ export type {Get} from './source/get';
101
102
  export type {LastArrayElement} from './source/last-array-element';
102
103
 
103
104
  // Miscellaneous
105
+ export type {GlobalThis} from './source/global-this';
104
106
  export type {PackageJson} from './source/package-json';
105
107
  export type {TsConfigJson} from './source/tsconfig-json';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-fest",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "A collection of essential TypeScript types",
5
5
  "license": "(MIT OR CC0-1.0)",
6
6
  "repository": "sindresorhus/type-fest",
package/readme.md CHANGED
@@ -169,6 +169,7 @@ Click the type names for complete docs.
169
169
  - [`RequiredKeysOf`](source/required-keys-of.d.ts) - Extract all required keys from the given type.
170
170
  - [`HasRequiredKeys`](source/has-required-keys.d.ts) - Create a `true`/`false` type depending on whether the given type has any required fields.
171
171
  - [`Spread`](source/spread.d.ts) - Mimic the type inferred by TypeScript when merging two objects or two arrays/tuples using the spread syntax.
172
+ - [`IsEqual`](source/is-equal.d.ts) - Returns a boolean for whether the two given types are equal.
172
173
 
173
174
  ### JSON
174
175
 
@@ -236,7 +237,8 @@ Click the type names for complete docs.
236
237
 
237
238
  ### Miscellaneous
238
239
 
239
- - [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). It also includes support for [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) and [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/).
240
+ - [`GlobalThis`](source/global-this.d.ts) - Declare locally scoped properties on `globalThis`.
241
+ - [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). It also includes support for [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html).
240
242
  - [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
241
243
 
242
244
  ## Declined types
@@ -623,13 +625,13 @@ There are many advanced types most users don't know about.
623
625
  // Mutate array randomly changing its' elements indexes.
624
626
  }
625
627
 
626
- function callNTimes<Fn extends (...args: any[]) => any> (func: Fn, callCount: number) {
628
+ function callNTimes<Fn extends (...arguments_: any[]) => any> (func: Fn, callCount: number) {
627
629
  // Type that represents the type of the received function parameters.
628
630
  type FunctionParameters = Parameters<Fn>;
629
631
 
630
- return function (...args: FunctionParameters) {
632
+ return function (...arguments_: FunctionParameters) {
631
633
  for (let i = 0; i < callCount; i++) {
632
- func(...args);
634
+ func(...arguments_);
633
635
  }
634
636
  }
635
637
  }
@@ -656,7 +658,7 @@ There are many advanced types most users don't know about.
656
658
  }
657
659
  }
658
660
 
659
- class InstanceCache<T extends (new (...args: any[]) => any)> {
661
+ class InstanceCache<T extends (new (...arguments_: any[]) => any)> {
660
662
  private ClassConstructor: T;
661
663
  private cache: Map<string, InstanceType<T>> = new Map();
662
664
 
@@ -664,18 +666,18 @@ There are many advanced types most users don't know about.
664
666
  this.ClassConstructor = ctr;
665
667
  }
666
668
 
667
- getInstance (...args: ConstructorParameters<T>): InstanceType<T> {
668
- const hash = this.calculateArgumentsHash(...args);
669
+ getInstance (...arguments_: ConstructorParameters<T>): InstanceType<T> {
670
+ const hash = this.calculateArgumentsHash(...arguments_);
669
671
 
670
672
  const existingInstance = this.cache.get(hash);
671
673
  if (existingInstance !== undefined) {
672
674
  return existingInstance;
673
675
  }
674
676
 
675
- return new this.ClassConstructor(...args);
677
+ return new this.ClassConstructor(...arguments_);
676
678
  }
677
679
 
678
- private calculateArgumentsHash(...args: any[]): string {
680
+ private calculateArgumentsHash(...arguments_: any[]): string {
679
681
  // Calculate hash.
680
682
  return 'hash';
681
683
  }
@@ -747,17 +749,17 @@ There are many advanced types most users don't know about.
747
749
  const instanceCounter: Map<Function, number> = new Map();
748
750
 
749
751
  interface Constructor {
750
- new(...args: any[]): any;
752
+ new(...arguments_: any[]): any;
751
753
  }
752
754
 
753
755
  // Keep track how many instances of `Constr` constructor have been created.
754
756
  function getInstance<
755
757
  Constr extends Constructor,
756
- Args extends ConstructorParameters<Constr>
757
- >(constructor: Constr, ...args: Args): InstanceType<Constr> {
758
+ Arguments extends ConstructorParameters<Constr>
759
+ >(constructor: Constr, ...arguments_: Arguments): InstanceType<Constr> {
758
760
  let count = instanceCounter.get(constructor) || 0;
759
761
 
760
- const instance = new constructor(...args);
762
+ const instance = new constructor(...arguments_);
761
763
 
762
764
  instanceCounter.set(constructor, count + 1);
763
765
 
@@ -1,4 +1,4 @@
1
- type AsyncFunction = (...args: any[]) => Promise<unknown>;
1
+ type AsyncFunction = (...arguments_: any[]) => Promise<unknown>;
2
2
 
3
3
  /**
4
4
  Unwrap the return type of a function that returns a `Promise`.
@@ -29,4 +29,4 @@ const getFooAsync: AsyncifiedFooGetter = (someArg) => {
29
29
 
30
30
  @category Async
31
31
  */
32
- export type Asyncify<Fn extends (...args: any[]) => any> = SetReturnType<Fn, Promise<Awaited<ReturnType<Fn>>>>;
32
+ export type Asyncify<Fn extends (...arguments_: any[]) => any> = SetReturnType<Fn, Promise<Awaited<ReturnType<Fn>>>>;
@@ -74,5 +74,7 @@ const dbResult: CamelCasedProperties<RawOptions> = {
74
74
  @category Template literal
75
75
  */
76
76
  export type CamelCase<Type, Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true}> = Type extends string
77
- ? Uncapitalize<CamelCaseFromArray<SplitWords<Type extends Uppercase<Type> ? Lowercase<Type> : Type>, Options>>
77
+ ? string extends Type
78
+ ? Type
79
+ : Uncapitalize<CamelCaseFromArray<SplitWords<Type extends Uppercase<Type> ? Lowercase<Type> : Type>, Options>>
78
80
  : Type;
@@ -1,5 +1,5 @@
1
1
  import type {Opaque} from './opaque';
2
- import type {IsEqual} from './internal';
2
+ import type {IsEqual} from './is-equal';
3
3
  import type {ConditionalExcept} from './conditional-except';
4
4
  import type {ConditionalSimplifyDeep} from './conditional-simplify';
5
5
 
package/source/exact.d.ts CHANGED
@@ -1,20 +1,5 @@
1
- import type {KeysOfUnion} from './internal';
2
-
3
- /**
4
- Extract the element of an array that also works for array union.
5
-
6
- Returns `never` if T is not an array.
7
-
8
- It creates a type-safe way to access the element type of `unknown` type.
9
- */
10
- type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
11
-
12
- /**
13
- Extract the object field type if T is an object and K is a key of T, return `never` otherwise.
14
-
15
- It creates a type-safe way to access the member type of `unknown` type.
16
- */
17
- type ObjectValue<T, K> = K extends keyof T ? T[K] : never;
1
+ import type {KeysOfUnion, ArrayElement, ObjectValue} from './internal';
2
+ import type {Opaque} from './opaque';
18
3
 
19
4
  /**
20
5
  Create a type from `ParameterType` and `InputType` and change keys exclusive to `InputType` to `never`.
@@ -35,7 +20,7 @@ This is useful for function type-guarding to reject arguments with excess proper
35
20
  ```
36
21
  type OnlyAcceptName = {name: string};
37
22
 
38
- function onlyAcceptName(args: OnlyAcceptName) {}
23
+ function onlyAcceptName(arguments_: OnlyAcceptName) {}
39
24
 
40
25
  // TypeScript complains about excess properties when an object literal is provided.
41
26
  onlyAcceptName({name: 'name', id: 1});
@@ -54,7 +39,7 @@ import {Exact} from 'type-fest';
54
39
 
55
40
  type OnlyAcceptName = {name: string};
56
41
 
57
- function onlyAcceptNameImproved<T extends Exact<OnlyAcceptName, T>>(args: T) {}
42
+ function onlyAcceptNameImproved<T extends Exact<OnlyAcceptName, T>>(arguments_: T) {}
58
43
 
59
44
  const invalidInput = {name: 'name', id: 1};
60
45
  onlyAcceptNameImproved(invalidInput); // Compilation error
@@ -69,5 +54,7 @@ export type Exact<ParameterType, InputType> =
69
54
  ParameterType extends unknown[] ? Array<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
70
55
  // In TypeScript, Array is a subtype of ReadonlyArray, so always test Array before ReadonlyArray.
71
56
  : ParameterType extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
72
- : ParameterType extends object ? ExactObject<ParameterType, InputType>
73
- : ParameterType;
57
+ // For Opaque types, internal details are hidden from public, so let's leave it as is.
58
+ : ParameterType extends Opaque<infer OpaqueType, infer OpaqueToken> ? ParameterType
59
+ : ParameterType extends object ? ExactObject<ParameterType, InputType>
60
+ : ParameterType;
@@ -1,4 +1,4 @@
1
- import type {IsEqual} from './internal';
1
+ import type {IsEqual} from './is-equal';
2
2
 
3
3
  /**
4
4
  Filter out keys from an object.
@@ -0,0 +1,21 @@
1
+ /**
2
+ Declare locally scoped properties on `globalThis`.
3
+
4
+ When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.
5
+
6
+ Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.
7
+
8
+ @example
9
+ ```
10
+ import type {GlobalThis} from 'type-fest';
11
+
12
+ type ExtraGlobals = GlobalThis & {
13
+ readonly GLOBAL_TOKEN: string;
14
+ };
15
+
16
+ (globalThis as ExtraGlobals).GLOBAL_TOKEN;
17
+ ```
18
+
19
+ @category Type
20
+ */
21
+ export type GlobalThis = typeof globalThis;
@@ -1,4 +1,4 @@
1
- import type {IsEqual} from './internal';
1
+ import type {IsEqual} from './is-equal';
2
2
 
3
3
  /**
4
4
  Returns a boolean for whether the given array includes the given item.
@@ -1,18 +1,6 @@
1
1
  import type {Primitive} from './primitive';
2
2
  import type {Simplify} from './simplify';
3
3
 
4
- /**
5
- Returns a boolean for whether the two given types are equal.
6
-
7
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
8
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
9
- */
10
- export type IsEqual<T, U> =
11
- (<G>() => G extends T ? 1 : 2) extends
12
- (<G>() => G extends U ? 1 : 2)
13
- ? true
14
- : false;
15
-
16
4
  /**
17
5
  Infer the length of the given array `<T>`.
18
6
 
@@ -95,6 +83,22 @@ Extracts the type of an array or tuple minus the first element.
95
83
  */
96
84
  export type ArrayTail<TArray extends UnknownArrayOrTuple> = TArray extends readonly [unknown, ...infer TTail] ? TTail : [];
97
85
 
86
+ /**
87
+ Extract the element of an array that also works for array union.
88
+
89
+ Returns `never` if T is not an array.
90
+
91
+ It creates a type-safe way to access the element type of `unknown` type.
92
+ */
93
+ export type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
94
+
95
+ /**
96
+ Extract the object field type if T is an object and K is a key of T, return `never` otherwise.
97
+
98
+ It creates a type-safe way to access the member type of `unknown` type.
99
+ */
100
+ export type ObjectValue<T, K> = K extends keyof T ? T[K] : never;
101
+
98
102
  /**
99
103
  Returns a boolean for whether the string is lowercased.
100
104
  */
@@ -117,6 +121,16 @@ Returns a boolean for whether the the type is `any`.
117
121
  */
118
122
  export type IsAny<T> = 0 extends 1 & T ? true : false;
119
123
 
124
+ /**
125
+ Returns a boolean for whether the the type is `never`.
126
+ */
127
+ export type IsNever<T> = [T] extends [never] ? true : false;
128
+
129
+ /**
130
+ Returns a boolean for whether the the type is `unknown`.
131
+ */
132
+ export type IsUnknown<T> = IsNever<T> extends false ? T extends unknown ? unknown extends T ? IsAny<T> extends false ? true : false : false : false : false;
133
+
120
134
  /**
121
135
  For an object T, if it has any properties that are a union with `undefined`, make those into optional properties instead.
122
136
 
@@ -149,7 +163,7 @@ type BaseKeyFilter<Type, Key extends keyof Type> = Key extends symbol
149
163
  ? never
150
164
  : Type[Key] extends symbol
151
165
  ? never
152
- : [(...args: any[]) => any] extends [Type[Key]]
166
+ : [(...arguments_: any[]) => any] extends [Type[Key]]
153
167
  ? never
154
168
  : Key;
155
169
 
@@ -0,0 +1,30 @@
1
+ /**
2
+ Returns a boolean for whether the two given types are equal.
3
+
4
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
5
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
6
+
7
+ Use-cases:
8
+ - If you want to make a conditional branch based on the result of a comparison of two types.
9
+
10
+ @example
11
+ ```
12
+ import type {IsEqual} from 'type-fest';
13
+
14
+ // This type returns a boolean for whether the given array includes the given item.
15
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
16
+ type Includes<Value extends readonly any[], Item> =
17
+ Value extends readonly [Value[0], ...infer rest]
18
+ ? IsEqual<Value[0], Item> extends true
19
+ ? true
20
+ : Includes<rest, Item>
21
+ : false;
22
+ ```
23
+
24
+ @category Utilities
25
+ */
26
+ export type IsEqual<A, B> =
27
+ (<G>() => G extends A ? 1 : 2) extends
28
+ (<G>() => G extends B ? 1 : 2)
29
+ ? true
30
+ : false;
package/source/join.d.ts CHANGED
@@ -21,13 +21,13 @@ const path: Join<[1, 2, 3], '.'> = [1, 2, 3].join('.');
21
21
  @category Template literal
22
22
  */
23
23
  export type Join<
24
- Strings extends Array<string | number>,
24
+ Strings extends Readonly<Array<string | number>>,
25
25
  Delimiter extends string,
26
26
  > = Strings extends []
27
27
  ? ''
28
28
  : Strings extends [string | number]
29
29
  ? `${Strings[0]}`
30
- : Strings extends [
30
+ : Strings extends readonly [
31
31
  string | number,
32
32
  ...infer Rest extends Array<string | number>,
33
33
  ]
@@ -5,7 +5,7 @@ import type {NegativeInfinity, PositiveInfinity} from './numeric';
5
5
  import type {TypedArray} from './typed-array';
6
6
 
7
7
  // Note: The return value has to be `any` and not `unknown` so it can match `void`.
8
- type NotJsonable = ((...args: any[]) => any) | undefined | symbol;
8
+ type NotJsonable = ((...arguments_: any[]) => any) | undefined | symbol;
9
9
 
10
10
  type JsonifyTuple<T extends [unknown, ...unknown[]]> = {
11
11
  [Key in keyof T]: T[Key] extends NotJsonable ? null : Jsonify<T[Key]>;
@@ -35,7 +35,7 @@ An interface cannot be structurally compared to `JsonValue` because an interface
35
35
 
36
36
  @example
37
37
  ```
38
- import type {Jsonify} from 'type-fest';
38
+ import type {Jsonify, JsonValue} from 'type-fest';
39
39
 
40
40
  interface Geometry {
41
41
  type: 'Point' | 'Polygon';
@@ -1,4 +1,5 @@
1
- import type {IsEqual, Subtract} from './internal';
1
+ import type {Subtract} from './internal';
2
+ import type {IsEqual} from './is-equal';
2
3
 
3
4
  type Recursive<T> = Array<Recursive<T>>;
4
5
 
@@ -1,4 +1,5 @@
1
- import type {IsEqual, Subtract} from './internal';
1
+ import type {Subtract} from './internal';
2
+ import type {IsEqual} from './is-equal';
2
3
 
3
4
  type Recursive<T> = ReadonlyArray<Recursive<T>>;
4
5
 
@@ -294,7 +294,7 @@ declare namespace PackageJson {
294
294
  };
295
295
 
296
296
  /**
297
- An alternative configuration for Yarn workspaces.
297
+ An alternative configuration for workspaces.
298
298
  */
299
299
  export type WorkspaceConfig = {
300
300
  /**
@@ -305,7 +305,8 @@ declare namespace PackageJson {
305
305
  /**
306
306
  Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns.
307
307
 
308
- [Read more](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/)
308
+ [Supported](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) by Yarn.
309
+ [Not supported](https://github.com/npm/rfcs/issues/287) by npm.
309
310
  */
310
311
  nohoist?: WorkspacePattern[];
311
312
  };
@@ -322,15 +323,6 @@ declare namespace PackageJson {
322
323
  type WorkspacePattern = string;
323
324
 
324
325
  export type YarnConfiguration = {
325
- /**
326
- Used to configure [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
327
-
328
- Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run `yarn install` once to install all of them in a single pass.
329
-
330
- Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
331
- */
332
- workspaces?: WorkspacePattern[] | WorkspaceConfig;
333
-
334
326
  /**
335
327
  If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command-line, set this to `true`.
336
328
 
@@ -624,6 +616,15 @@ declare namespace PackageJson {
624
616
  */
625
617
  url: string;
626
618
  };
619
+
620
+ /**
621
+ Used to configure [npm workspaces](https://docs.npmjs.com/cli/using-npm/workspaces) / [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
622
+
623
+ Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run your install command once in order to install all of them in a single pass.
624
+
625
+ Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
626
+ */
627
+ workspaces?: WorkspacePattern[] | WorkspaceConfig;
627
628
  }
628
629
 
629
630
  /**
@@ -1,7 +1,4 @@
1
- import type {IsAny} from './internal';
2
-
3
- type IsNever<T> = [T] extends [never] ? true : false;
4
- type IsUnknown<T> = IsNever<T> extends false ? T extends unknown ? unknown extends T ? IsAny<T> extends false ? true : false : false : false : false;
1
+ import type {IsUnknown} from './internal';
5
2
 
6
3
  /**
7
4
  Create a function type with a return type of your choice and the same parameters as the given function type.
@@ -20,13 +17,13 @@ type MyWrappedFunction = SetReturnType<MyFunctionThatCanThrow, SomeOtherType | u
20
17
 
21
18
  @category Function
22
19
  */
23
- export type SetReturnType<Fn extends (...args: any[]) => any, TypeToReturn> =
20
+ export type SetReturnType<Fn extends (...arguments_: any[]) => any, TypeToReturn> =
24
21
  // Just using `Parameters<Fn>` isn't ideal because it doesn't handle the `this` fake parameter.
25
- Fn extends (this: infer ThisArg, ...args: infer Arguments) => any ? (
22
+ Fn extends (this: infer ThisArg, ...arguments_: infer Arguments) => any ? (
26
23
  // If a function did not specify the `this` fake parameter, it will be inferred to `unknown`.
27
24
  // We want to detect this situation just to display a friendlier type upon hovering on an IntelliSense-powered IDE.
28
- IsUnknown<ThisArg> extends true ? (...args: Arguments) => TypeToReturn : (this: ThisArg, ...args: Arguments) => TypeToReturn
25
+ IsUnknown<ThisArg> extends true ? (...arguments_: Arguments) => TypeToReturn : (this: ThisArg, ...arguments_: Arguments) => TypeToReturn
29
26
  ) : (
30
27
  // This part should be unreachable, but we make it meaningful just in case…
31
- (...args: Parameters<Fn>) => TypeToReturn
28
+ (...arguments_: Parameters<Fn>) => TypeToReturn
32
29
  );
@@ -221,6 +221,21 @@ declare namespace TsConfigJson {
221
221
  | 'useFsEventsOnParentDirectory'
222
222
  | 'fixedChunkSizePolling';
223
223
 
224
+ export type ModuleResolution =
225
+ | 'classic'
226
+ | 'node'
227
+ | 'node16'
228
+ | 'nodenext'
229
+ // Pascal-cased alternatives
230
+ | 'Classic'
231
+ | 'Node'
232
+ | 'Node16'
233
+ | 'NodeNext';
234
+
235
+ export type ModuleDetection =
236
+ | 'auto'
237
+ | 'legacy'
238
+ | 'force';
224
239
  }
225
240
 
226
241
  export type CompilerOptions = {
@@ -247,8 +262,6 @@ declare namespace TsConfigJson {
247
262
 
248
263
  /**
249
264
  Specify output directory for generated declaration files.
250
-
251
- Requires TypeScript version 2.0 or later.
252
265
  */
253
266
  declarationDir?: string;
254
267
 
@@ -262,8 +275,6 @@ declare namespace TsConfigJson {
262
275
  /**
263
276
  Reduce the number of projects loaded automatically by TypeScript.
264
277
 
265
- Requires TypeScript version 4.0 or later.
266
-
267
278
  @default false
268
279
  */
269
280
  disableReferencedProjectLoad?: boolean;
@@ -271,8 +282,6 @@ declare namespace TsConfigJson {
271
282
  /**
272
283
  Enforces using indexed accessors for keys declared using an indexed type.
273
284
 
274
- Requires TypeScript version 4.2 or later.
275
-
276
285
  @default false
277
286
  */
278
287
  noPropertyAccessFromIndexSignature?: boolean;
@@ -294,8 +303,6 @@ declare namespace TsConfigJson {
294
303
  /**
295
304
  Differentiate between undefined and not present when type checking.
296
305
 
297
- Requires TypeScript version 4.4 or later.
298
-
299
306
  @default false
300
307
  */
301
308
  exactOptionalPropertyTypes?: boolean;
@@ -347,8 +354,6 @@ declare namespace TsConfigJson {
347
354
  /**
348
355
  Specify the JSX factory function to use when targeting React JSX emit, e.g. `React.createElement` or `h`.
349
356
 
350
- Requires TypeScript version 2.1 or later.
351
-
352
357
  @default 'React.createElement'
353
358
  */
354
359
  jsxFactory?: string;
@@ -356,8 +361,6 @@ declare namespace TsConfigJson {
356
361
  /**
357
362
  Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
358
363
 
359
- Requires TypeScript version 4.0 or later.
360
-
361
364
  @default 'React.Fragment'
362
365
  */
363
366
  jsxFragmentFactory?: string;
@@ -365,8 +368,6 @@ declare namespace TsConfigJson {
365
368
  /**
366
369
  Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.
367
370
 
368
- Requires TypeScript version 4.1 or later.
369
-
370
371
  @default 'react'
371
372
  */
372
373
  jsxImportSource?: string;
@@ -395,7 +396,7 @@ declare namespace TsConfigJson {
395
396
 
396
397
  @default ['AMD', 'System', 'ES6'].includes(module) ? 'classic' : 'node'
397
398
  */
398
- moduleResolution?: 'classic' | 'node';
399
+ moduleResolution?: CompilerOptions.ModuleResolution;
399
400
 
400
401
  /**
401
402
  Specifies the end of line sequence to be used when emitting files: 'crlf' (Windows) or 'lf' (Unix).
@@ -442,8 +443,6 @@ declare namespace TsConfigJson {
442
443
  /**
443
444
  Report errors on unused locals.
444
445
 
445
- Requires TypeScript version 2.0 or later.
446
-
447
446
  @default false
448
447
  */
449
448
  noUnusedLocals?: boolean;
@@ -451,8 +450,6 @@ declare namespace TsConfigJson {
451
450
  /**
452
451
  Report errors on unused parameters.
453
452
 
454
- Requires TypeScript version 2.0 or later.
455
-
456
453
  @default false
457
454
  */
458
455
  noUnusedParameters?: boolean;
@@ -486,8 +483,6 @@ declare namespace TsConfigJson {
486
483
  /**
487
484
  Skip type checking of declaration files.
488
485
 
489
- Requires TypeScript version 2.0 or later.
490
-
491
486
  @default false
492
487
  */
493
488
  skipLibCheck?: boolean;
@@ -592,8 +587,6 @@ declare namespace TsConfigJson {
592
587
  /**
593
588
  Default catch clause variables as `unknown` instead of `any`.
594
589
 
595
- Requires TypeScript version 4.4 or later.
596
-
597
590
  @default false
598
591
  */
599
592
  useUnknownInCatchVariables?: boolean;
@@ -609,8 +602,6 @@ declare namespace TsConfigJson {
609
602
  /**
610
603
  Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
611
604
 
612
- Requires TypeScript version 3.8 or later.
613
-
614
605
  @deprecated Use watchOptions.fallbackPolling instead.
615
606
  */
616
607
  fallbackPolling?: CompilerOptions.FallbackPolling;
@@ -618,8 +609,6 @@ declare namespace TsConfigJson {
618
609
  /**
619
610
  Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
620
611
 
621
- Requires TypeScript version 3.8 or later.
622
-
623
612
  @default 'useFsEvents'
624
613
  @deprecated Use watchOptions.watchDirectory instead.
625
614
  */
@@ -628,8 +617,6 @@ declare namespace TsConfigJson {
628
617
  /**
629
618
  Specify the strategy for watching individual files.
630
619
 
631
- Requires TypeScript version 3.8 or later.
632
-
633
620
  @default 'useFsEvents'
634
621
  @deprecated Use watchOptions.watchFile instead.
635
622
  */
@@ -666,8 +653,6 @@ declare namespace TsConfigJson {
666
653
  /**
667
654
  Add `undefined` to a type when accessed using an index.
668
655
 
669
- Requires TypeScript version 4.1 or later.
670
-
671
656
  @default false
672
657
  */
673
658
  noUncheckedIndexedAccess?: boolean;
@@ -703,8 +688,6 @@ declare namespace TsConfigJson {
703
688
  /**
704
689
  Emit a v8 CPU profile of the compiler run for debugging.
705
690
 
706
- Requires TypeScript version 3.7 or later.
707
-
708
691
  @default 'profile.cpuprofile'
709
692
  */
710
693
  generateCpuProfile?: string;
@@ -721,8 +704,6 @@ declare namespace TsConfigJson {
721
704
 
722
705
  /**
723
706
  List of TypeScript language server plugins to load.
724
-
725
- Requires TypeScript version 2.3 or later.
726
707
  */
727
708
  plugins?: CompilerOptions.Plugin[];
728
709
 
@@ -733,15 +714,11 @@ declare namespace TsConfigJson {
733
714
 
734
715
  /**
735
716
  Specify list of directories for type definition files to be included.
736
-
737
- Requires TypeScript version 2.0 or later.
738
717
  */
739
718
  typeRoots?: string[];
740
719
 
741
720
  /**
742
721
  Type declaration files to be included in compilation.
743
-
744
- Requires TypeScript version 2.0 or later.
745
722
  */
746
723
  types?: string[];
747
724
 
@@ -783,8 +760,6 @@ declare namespace TsConfigJson {
783
760
  /**
784
761
  Enable to list all emitted files.
785
762
 
786
- Requires TypeScript version 2.0 or later.
787
-
788
763
  @default false
789
764
  */
790
765
  listEmittedFiles?: boolean;
@@ -792,24 +767,18 @@ declare namespace TsConfigJson {
792
767
  /**
793
768
  Disable size limit for JavaScript project.
794
769
 
795
- Requires TypeScript version 2.0 or later.
796
-
797
770
  @default false
798
771
  */
799
772
  disableSizeLimit?: boolean;
800
773
 
801
774
  /**
802
775
  List of library files to be included in the compilation.
803
-
804
- Requires TypeScript version 2.0 or later.
805
776
  */
806
777
  lib?: CompilerOptions.Lib[];
807
778
 
808
779
  /**
809
780
  Enable strict null checks.
810
781
 
811
- Requires TypeScript version 2.0 or later.
812
-
813
782
  @default false
814
783
  */
815
784
  strictNullChecks?: boolean;
@@ -824,8 +793,6 @@ declare namespace TsConfigJson {
824
793
  /**
825
794
  Import emit helpers (e.g. `__extends`, `__rest`, etc..) from tslib.
826
795
 
827
- Requires TypeScript version 2.1 or later.
828
-
829
796
  @default false
830
797
  */
831
798
  importHelpers?: boolean;
@@ -840,8 +807,6 @@ declare namespace TsConfigJson {
840
807
  /**
841
808
  Parse in strict mode and emit `'use strict'` for each source file.
842
809
 
843
- Requires TypeScript version 2.1 or later.
844
-
845
810
  @default false
846
811
  */
847
812
  alwaysStrict?: boolean;
@@ -849,8 +814,6 @@ declare namespace TsConfigJson {
849
814
  /**
850
815
  Enable all strict type checking options.
851
816
 
852
- Requires TypeScript version 2.3 or later.
853
-
854
817
  @default false
855
818
  */
856
819
  strict?: boolean;
@@ -865,8 +828,6 @@ declare namespace TsConfigJson {
865
828
  /**
866
829
  Provide full support for iterables in `for-of`, spread, and destructuring when targeting `ES5` or `ES3`.
867
830
 
868
- Requires TypeScript version 2.3 or later.
869
-
870
831
  @default false
871
832
  */
872
833
  downlevelIteration?: boolean;
@@ -874,8 +835,6 @@ declare namespace TsConfigJson {
874
835
  /**
875
836
  Report errors in `.js` files.
876
837
 
877
- Requires TypeScript version 2.3 or later.
878
-
879
838
  @default false
880
839
  */
881
840
  checkJs?: boolean;
@@ -883,8 +842,6 @@ declare namespace TsConfigJson {
883
842
  /**
884
843
  Disable bivariant parameter checking for function types.
885
844
 
886
- Requires TypeScript version 2.6 or later.
887
-
888
845
  @default false
889
846
  */
890
847
  strictFunctionTypes?: boolean;
@@ -892,8 +849,6 @@ declare namespace TsConfigJson {
892
849
  /**
893
850
  Ensure non-undefined class properties are initialized in the constructor.
894
851
 
895
- Requires TypeScript version 2.7 or later.
896
-
897
852
  @default false
898
853
  */
899
854
  strictPropertyInitialization?: boolean;
@@ -901,8 +856,6 @@ declare namespace TsConfigJson {
901
856
  /**
902
857
  Emit `__importStar` and `__importDefault` helpers for runtime Babel ecosystem compatibility and enable `--allowSyntheticDefaultImports` for typesystem compatibility.
903
858
 
904
- Requires TypeScript version 2.7 or later.
905
-
906
859
  @default false
907
860
  */
908
861
  esModuleInterop?: boolean;
@@ -917,8 +870,6 @@ declare namespace TsConfigJson {
917
870
  /**
918
871
  Resolve `keyof` to string valued property names only (no numbers or symbols).
919
872
 
920
- Requires TypeScript version 2.9 or later.
921
-
922
873
  @default false
923
874
  */
924
875
  keyofStringsOnly?: boolean;
@@ -926,8 +877,6 @@ declare namespace TsConfigJson {
926
877
  /**
927
878
  Emit ECMAScript standard class fields.
928
879
 
929
- Requires TypeScript version 3.7 or later.
930
-
931
880
  @default false
932
881
  */
933
882
  useDefineForClassFields?: boolean;
@@ -935,8 +884,6 @@ declare namespace TsConfigJson {
935
884
  /**
936
885
  Generates a sourcemap for each corresponding `.d.ts` file.
937
886
 
938
- Requires TypeScript version 2.9 or later.
939
-
940
887
  @default false
941
888
  */
942
889
  declarationMap?: boolean;
@@ -944,8 +891,6 @@ declare namespace TsConfigJson {
944
891
  /**
945
892
  Include modules imported with `.json` extension.
946
893
 
947
- Requires TypeScript version 2.9 or later.
948
-
949
894
  @default false
950
895
  */
951
896
  resolveJsonModule?: boolean;
@@ -953,8 +898,6 @@ declare namespace TsConfigJson {
953
898
  /**
954
899
  Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.
955
900
 
956
- Requires TypeScript version 3.8 or later.
957
-
958
901
  @default false
959
902
  */
960
903
  assumeChangesOnlyAffectDirectDependencies?: boolean;
@@ -983,8 +926,6 @@ declare namespace TsConfigJson {
983
926
  /**
984
927
  Opt a project out of multi-project reference checking when editing.
985
928
 
986
- Requires TypeScript version 3.8 or later.
987
-
988
929
  @default false
989
930
  */
990
931
  disableSolutionSearching?: boolean;
@@ -992,11 +933,28 @@ declare namespace TsConfigJson {
992
933
  /**
993
934
  Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
994
935
 
995
- Requires TypeScript version 4.2 or later.
996
-
997
936
  @default false
998
937
  */
999
938
  explainFiles?: boolean;
939
+
940
+ /**
941
+ Preserve unused imported values in the JavaScript output that would otherwise be removed.
942
+
943
+ @default true
944
+ */
945
+ preserveValueImports?: boolean;
946
+
947
+ /**
948
+ List of file name suffixes to search when resolving a module.
949
+ */
950
+ moduleSuffixes?: string[];
951
+
952
+ /**
953
+ Control what method is used to detect module-format JS files.
954
+
955
+ @default 'auto'
956
+ */
957
+ moduleDetection?: CompilerOptions.ModuleDetection;
1000
958
  };
1001
959
 
1002
960
  namespace WatchOptions {
@@ -1026,8 +984,6 @@ declare namespace TsConfigJson {
1026
984
  /**
1027
985
  Specify the strategy for watching individual files.
1028
986
 
1029
- Requires TypeScript version 3.8 or later.
1030
-
1031
987
  @default 'UseFsEvents'
1032
988
  */
1033
989
  watchFile?: WatchOptions.WatchFileKind | Lowercase<WatchOptions.WatchFileKind>;
@@ -1035,16 +991,12 @@ declare namespace TsConfigJson {
1035
991
  /**
1036
992
  Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
1037
993
 
1038
- Requires TypeScript version 3.8 or later.
1039
-
1040
994
  @default 'UseFsEvents'
1041
995
  */
1042
996
  watchDirectory?: WatchOptions.WatchDirectoryKind | Lowercase<WatchOptions.WatchDirectoryKind>;
1043
997
 
1044
998
  /**
1045
999
  Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
1046
-
1047
- Requires TypeScript version 3.8 or later.
1048
1000
  */
1049
1001
  fallbackPolling?: WatchOptions.PollingWatchKind | Lowercase<WatchOptions.PollingWatchKind>;
1050
1002
 
@@ -1066,8 +1018,6 @@ declare namespace TsConfigJson {
1066
1018
 
1067
1019
  /**
1068
1020
  Auto type (.d.ts) acquisition options for this project.
1069
-
1070
- Requires TypeScript version 2.1 or later.
1071
1021
  */
1072
1022
  export type TypeAcquisition = {
1073
1023
  /**
@@ -1129,8 +1079,6 @@ export type TsConfigJson = {
1129
1079
 
1130
1080
  /**
1131
1081
  Auto type (.d.ts) acquisition options for this project.
1132
-
1133
- Requires TypeScript version 2.1 or later.
1134
1082
  */
1135
1083
  typeAcquisition?: TsConfigJson.TypeAcquisition;
1136
1084
 
@@ -1141,8 +1089,6 @@ export type TsConfigJson = {
1141
1089
 
1142
1090
  /**
1143
1091
  Path to base configuration file to inherit from.
1144
-
1145
- Requires TypeScript version 2.1 or later.
1146
1092
  */
1147
1093
  extends?: string;
1148
1094
 
@@ -1162,15 +1108,11 @@ export type TsConfigJson = {
1162
1108
  Specifies a list of glob patterns that match files to be included in compilation.
1163
1109
 
1164
1110
  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`.
1165
-
1166
- Requires TypeScript version 2.0 or later.
1167
1111
  */
1168
1112
  include?: string[];
1169
1113
 
1170
1114
  /**
1171
1115
  Referenced projects.
1172
-
1173
- Requires TypeScript version 3.0 or later.
1174
1116
  */
1175
1117
  references?: TsConfigJson.References[];
1176
1118
  };