type-fest 3.5.2 → 3.5.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/source/exact.d.ts +10 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-fest",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
4
4
  "description": "A collection of essential TypeScript types",
5
5
  "license": "(MIT OR CC0-1.0)",
6
6
  "repository": "sindresorhus/type-fest",
package/source/exact.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type {KeysOfUnion, ArrayElement, ObjectValue} from './internal';
2
2
  import type {Opaque} from './opaque';
3
+ import type {IsEqual} from './is-equal';
3
4
 
4
5
  /**
5
6
  Create a type from `ParameterType` and `InputType` and change keys exclusive to `InputType` to `never`.
@@ -50,11 +51,12 @@ onlyAcceptNameImproved(invalidInput); // Compilation error
50
51
  @category Utilities
51
52
  */
52
53
  export type Exact<ParameterType, InputType> =
53
- // Convert union of array to array of union: A[] & B[] => (A & B)[]
54
- ParameterType extends unknown[] ? Array<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
55
- // In TypeScript, Array is a subtype of ReadonlyArray, so always test Array before ReadonlyArray.
56
- : ParameterType extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
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;
54
+ IsEqual<ParameterType, InputType> extends true ? ParameterType
55
+ // Convert union of array to array of union: A[] & B[] => (A & B)[]
56
+ : ParameterType extends unknown[] ? Array<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
57
+ // In TypeScript, Array is a subtype of ReadonlyArray, so always test Array before ReadonlyArray.
58
+ : ParameterType extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>>
59
+ // For Opaque types, internal details are hidden from public, so let's leave it as is.
60
+ : ParameterType extends Opaque<infer OpaqueType, infer OpaqueToken> ? ParameterType
61
+ : ParameterType extends object ? ExactObject<ParameterType, InputType>
62
+ : ParameterType;