type-fest 5.5.0 → 5.6.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.
Files changed (82) hide show
  1. package/index.d.ts +3 -0
  2. package/package.json +6 -4
  3. package/readme.md +70 -55
  4. package/source/absolute.d.ts +52 -0
  5. package/source/all-union-fields.d.ts +18 -18
  6. package/source/and.d.ts +1 -1
  7. package/source/array-splice.d.ts +24 -24
  8. package/source/camel-case.d.ts +38 -5
  9. package/source/camel-cased-properties-deep.d.ts +11 -4
  10. package/source/camel-cased-properties.d.ts +5 -1
  11. package/source/delimiter-case.d.ts +1 -0
  12. package/source/delimiter-cased-properties-deep.d.ts +8 -1
  13. package/source/delimiter-cased-properties.d.ts +5 -1
  14. package/source/empty-object.d.ts +1 -1
  15. package/source/entries.d.ts +1 -1
  16. package/source/entry.d.ts +1 -1
  17. package/source/get.d.ts +1 -1
  18. package/source/greater-than.d.ts +3 -2
  19. package/source/has-optional-keys.d.ts +1 -1
  20. package/source/has-readonly-keys.d.ts +1 -1
  21. package/source/has-required-keys.d.ts +1 -1
  22. package/source/has-writable-keys.d.ts +1 -1
  23. package/source/int-closed-range.d.ts +1 -3
  24. package/source/int-range.d.ts +3 -5
  25. package/source/internal/array.d.ts +7 -7
  26. package/source/internal/keys.d.ts +9 -9
  27. package/source/internal/numeric.d.ts +13 -23
  28. package/source/internal/tuple.d.ts +2 -2
  29. package/source/is-integer.d.ts +8 -8
  30. package/source/is-literal.d.ts +5 -5
  31. package/source/is-union.d.ts +12 -12
  32. package/source/iterable-element.d.ts +5 -5
  33. package/source/jsonify.d.ts +4 -4
  34. package/source/kebab-case.d.ts +1 -0
  35. package/source/kebab-cased-properties-deep.d.ts +7 -0
  36. package/source/kebab-cased-properties.d.ts +5 -1
  37. package/source/keys-of-union.d.ts +2 -2
  38. package/source/less-than-or-equal.d.ts +1 -1
  39. package/source/literal-to-primitive.d.ts +1 -1
  40. package/source/literal-union.d.ts +1 -1
  41. package/source/merge-exclusive.d.ts +3 -3
  42. package/source/multidimensional-array.d.ts +1 -1
  43. package/source/multidimensional-readonly-array.d.ts +1 -1
  44. package/source/non-nullable-deep.d.ts +102 -0
  45. package/source/numeric.d.ts +3 -3
  46. package/source/omit-deep.d.ts +22 -22
  47. package/source/or.d.ts +1 -1
  48. package/source/package-json.d.ts +7 -7
  49. package/source/partial-deep.d.ts +3 -1
  50. package/source/pascal-case.d.ts +1 -0
  51. package/source/pascal-cased-properties-deep.d.ts +7 -0
  52. package/source/pascal-cased-properties.d.ts +5 -1
  53. package/source/pick-deep.d.ts +2 -0
  54. package/source/readonly-deep.d.ts +5 -3
  55. package/source/remove-prefix.d.ts +15 -15
  56. package/source/replace.d.ts +2 -2
  57. package/source/require-all-or-none.d.ts +1 -1
  58. package/source/require-at-least-one.d.ts +5 -7
  59. package/source/require-exactly-one.d.ts +3 -3
  60. package/source/require-one-or-none.d.ts +1 -1
  61. package/source/required-deep.d.ts +3 -1
  62. package/source/screaming-snake-case.d.ts +1 -0
  63. package/source/set-non-nullable-deep.d.ts +6 -3
  64. package/source/set-non-nullable.d.ts +1 -1
  65. package/source/set-optional.d.ts +5 -5
  66. package/source/set-readonly.d.ts +3 -3
  67. package/source/set-required-deep.d.ts +1 -1
  68. package/source/set-required.d.ts +3 -3
  69. package/source/shared-union-fields.d.ts +9 -9
  70. package/source/snake-case.d.ts +1 -0
  71. package/source/snake-cased-properties-deep.d.ts +7 -0
  72. package/source/snake-cased-properties.d.ts +5 -1
  73. package/source/subtract.d.ts +4 -3
  74. package/source/sum.d.ts +5 -4
  75. package/source/tagged.d.ts +3 -5
  76. package/source/tsconfig-json.d.ts +39 -7
  77. package/source/union-length.d.ts +27 -0
  78. package/source/union-to-intersection.d.ts +1 -1
  79. package/source/union-to-tuple.d.ts +8 -4
  80. package/source/words.d.ts +30 -4
  81. package/source/writable.d.ts +14 -14
  82. package/source/xor.d.ts +1 -1
package/index.d.ts CHANGED
@@ -52,6 +52,7 @@ export type {SetRequired} from './source/set-required.d.ts';
52
52
  export type {SetRequiredDeep} from './source/set-required-deep.d.ts';
53
53
  export type {SetNonNullable} from './source/set-non-nullable.d.ts';
54
54
  export type {SetNonNullableDeep} from './source/set-non-nullable-deep.d.ts';
55
+ export type {NonNullableDeep} from './source/non-nullable-deep.d.ts';
55
56
  export type {ValueOf} from './source/value-of.d.ts';
56
57
  export type {AsyncReturnType} from './source/async-return-type.d.ts';
57
58
  export type {ConditionalExcept} from './source/conditional-except.d.ts';
@@ -173,6 +174,8 @@ export type {TupleOf} from './source/tuple-of.d.ts';
173
174
  export type {ExclusifyUnion} from './source/exclusify-union.d.ts';
174
175
  export type {ArrayReverse} from './source/array-reverse.d.ts';
175
176
  export type {UnionMember} from './source/union-member.d.ts';
177
+ export type {Absolute} from './source/absolute.d.ts';
178
+ export type {UnionLength} from './source/union-length.d.ts';
176
179
 
177
180
  // Template literal types
178
181
  export type {CamelCase, CamelCaseOptions} from './source/camel-case.d.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-fest",
3
- "version": "5.5.0",
3
+ "version": "5.6.0",
4
4
  "description": "A collection of essential TypeScript types",
5
5
  "license": "(MIT OR CC0-1.0)",
6
6
  "repository": "sindresorhus/type-fest",
@@ -27,7 +27,7 @@
27
27
  "scripts": {
28
28
  "test:tsc": "node --max-old-space-size=6144 ./node_modules/.bin/tsc",
29
29
  "test:tsd": "node --max-old-space-size=6144 ./node_modules/.bin/tsd",
30
- "test:xo": "node --max-old-space-size=6144 ./node_modules/.bin/xo --ignores=lint-processors/fixtures/**/*.d.ts",
30
+ "test:xo": "node --max-old-space-size=6144 ./node_modules/.bin/xo --ignores=lint-processors/fixtures/**/*.d.ts '**/*.{js,ts,md}'",
31
31
  "test:linter": "node --test",
32
32
  "test": "run-p test:*"
33
33
  },
@@ -53,17 +53,19 @@
53
53
  "tagged-tag": "^1.0.0"
54
54
  },
55
55
  "devDependencies": {
56
+ "@eslint/markdown": "^8.0.1",
56
57
  "@sindresorhus/tsconfig": "^8.0.1",
58
+ "@types/node": "^25.5.0",
57
59
  "@typescript-eslint/parser": "^8.44.0",
58
- "eslint": "^9.35.0",
59
60
  "@typescript/vfs": "^1.6.1",
60
61
  "dedent": "^1.7.0",
62
+ "eslint": "^10.1.0",
61
63
  "expect-type": "^1.2.2",
62
64
  "npm-run-all2": "^8.0.4",
63
65
  "tsd": "^0.33.0",
64
66
  "typescript": "^5.9.2",
65
67
  "typescript-eslint": "^8.47.0",
66
- "xo": "^1.2.2"
68
+ "xo": "^2.0.2"
67
69
  },
68
70
  "tsd": {
69
71
  "compilerOptions": {
package/readme.md CHANGED
@@ -29,6 +29,17 @@
29
29
  <sup>An open-source framework that supports any programming language, cloud provider, or deployment automation tool.</sup>
30
30
  </div>
31
31
  </a>
32
+ <br>
33
+ <br>
34
+ <a href="https://circleback.ai?utm_source=sindresorhus&utm_medium=sponsorship&utm_campaign=awesome-list&utm_id=type-fest">
35
+ <div>
36
+ <img width="300" src="https://sindresorhus.com/assets/thanks/circleback-logo.png?x" alt="Circleback logo">
37
+ </div>
38
+ <b>Get the most out of every conversation.</b>
39
+ <div>
40
+ <sup>AI-powered meeting notes, automations, and search. Give AI agents the context they need to get things done.</sup>
41
+ </div>
42
+ </a>
32
43
  </p>
33
44
  </div>
34
45
  <br>
@@ -102,51 +113,52 @@ Click the type names for complete docs.
102
113
  - [`UnknownArray`](source/unknown-array.d.ts) - Represents an array with `unknown` value.
103
114
  - [`UnknownMap`](source/unknown-map.d.ts) - Represents a map with `unknown` key and value.
104
115
  - [`UnknownSet`](source/unknown-set.d.ts) - Represents a set with `unknown` value.
105
- - [`Except`](source/except.d.ts) - Create a type from an object type without certain keys. This is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys).
116
+ - [`Except`](source/except.d.ts) - Create a type from an object type without certain keys.
106
117
  - [`Writable`](source/writable.d.ts) - Create a type that strips `readonly` from the given type. Inverse of `Readonly<T>`.
107
118
  - [`WritableDeep`](source/writable-deep.d.ts) - Create a deeply mutable version of an `object`/`ReadonlyMap`/`ReadonlySet`/`ReadonlyArray` type. The inverse of `ReadonlyDeep<T>`. Use `Writable<T>` if you only need one level deep.
108
119
  - [`Merge`](source/merge.d.ts) - Merge two types into a new type. Keys of the second type overrides keys of the first type.
109
120
  - [`ObjectMerge`](source/object-merge.d.ts) - Merge two object types into a new object type, where keys from the second override keys from the first.
110
121
  - [`MergeDeep`](source/merge-deep.d.ts) - Merge two objects or two arrays/tuples recursively into a new type.
111
122
  - [`MergeExclusive`](source/merge-exclusive.d.ts) - Create a type that has mutually exclusive keys.
112
- - [`OverrideProperties`](source/override-properties.d.ts) - Override only existing properties of the given type. Similar to `Merge`, but enforces that the original type has the properties you want to override.
113
- - [`RequireAtLeastOne`](source/require-at-least-one.d.ts) - Create a type that requires at least one of the given keys.
114
- - [`RequireExactlyOne`](source/require-exactly-one.d.ts) - Create a type that requires exactly a single key of the given keys and disallows more.
115
- - [`RequireAllOrNone`](source/require-all-or-none.d.ts) - Create a type that requires all of the given keys or none of the given keys.
116
- - [`RequireOneOrNone`](source/require-one-or-none.d.ts) - Create a type that requires exactly a single key of the given keys and disallows more, or none of the given keys.
123
+ - [`OverrideProperties`](source/override-properties.d.ts) - Override existing properties of the given type. Similar to `Merge`, but enforces that the original type has the properties you want to override.
124
+ - [`RequireAtLeastOne`](source/require-at-least-one.d.ts) - Create a type that requires at least one of the given keys, while keeping the remaining keys as is.
125
+ - [`RequireExactlyOne`](source/require-exactly-one.d.ts) - Create a type that requires exactly one of the given keys and disallows more, while keeping the remaining keys as is.
126
+ - [`RequireAllOrNone`](source/require-all-or-none.d.ts) - Create a type that requires all of the given keys or none of the given keys, while keeping the remaining keys as is.
127
+ - [`RequireOneOrNone`](source/require-one-or-none.d.ts) - Create a type that requires exactly one of the given keys or none of the given keys, while keeping the remaining keys as is.
117
128
  - [`SingleKeyObject`](source/single-key-object.d.ts) - Create a type that only accepts an object with a single key.
118
- - [`RequiredDeep`](source/required-deep.d.ts) - Create a deeply required version of another type. Use [`Required<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype) if you only need one level deep.
119
- - [`PickDeep`](source/pick-deep.d.ts) - Pick properties from a deeply-nested object. Use [`Pick<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys) if you only need one level deep.
120
- - [`OmitDeep`](source/omit-deep.d.ts) - Omit properties from a deeply-nested object. Use [`Omit<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys) if you only need one level deep.
129
+ - [`RequiredDeep`](source/required-deep.d.ts) - Create a deeply required version of another type.
130
+ - [`PickDeep`](source/pick-deep.d.ts) - Pick properties from a deeply-nested object.
131
+ - [`OmitDeep`](source/omit-deep.d.ts) - Omit properties from a deeply-nested object.
121
132
  - [`OmitIndexSignature`](source/omit-index-signature.d.ts) - Omit any index signatures from the given object type, leaving only explicitly defined properties.
122
133
  - [`PickIndexSignature`](source/pick-index-signature.d.ts) - Pick only index signatures from the given object type, leaving out all explicitly defined properties.
123
- - [`PartialDeep`](source/partial-deep.d.ts) - Create a deeply optional version of another type. Use [`Partial<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype) if you only need one level deep.
134
+ - [`PartialDeep`](source/partial-deep.d.ts) - Create a deeply optional version of another type.
124
135
  - [`PartialOnUndefinedDeep`](source/partial-on-undefined-deep.d.ts) - Create a deep version of another type where all keys accepting `undefined` type are set to optional.
125
136
  - [`UndefinedOnPartialDeep`](source/undefined-on-partial-deep.d.ts) - Create a deep version of another type where all optional keys are set to also accept `undefined`.
126
137
  - [`UnwrapPartial`](source/unwrap-partial.d.ts) - Revert the `Partial` modifier on an object type.
127
- - [`ReadonlyDeep`](source/readonly-deep.d.ts) - Create a deeply immutable version of an `object`/`Map`/`Set`/`Array` type. Use [`Readonly<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype) if you only need one level deep.
128
- - [`LiteralUnion`](source/literal-union.d.ts) - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union. Workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729).
129
- - [`Tagged`](source/tagged.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf). (This replaces the previous [`Opaque`](source/tagged.d.ts) type, which is now deprecated.)
130
- - [`UnwrapTagged`](source/tagged.d.ts) - Get the untagged portion of a tagged type created with `Tagged`. (This replaces the previous [`UnwrapOpaque`](source/tagged.d.ts) type, which is now deprecated.)
138
+ - [`ReadonlyDeep`](source/readonly-deep.d.ts) - Create a deeply immutable version of another type.
139
+ - [`LiteralUnion`](source/literal-union.d.ts) - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
140
+ - [`Tagged`](source/tagged.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf).
141
+ - [`UnwrapTagged`](source/tagged.d.ts) - Get the untagged portion of a tagged type created with `Tagged`.
131
142
  - [`InvariantOf`](source/invariant-of.d.ts) - Create an [invariant type](https://basarat.gitbook.io/typescript/type-system/type-compatibility#footnote-invariance), which is a type that does not accept supertypes and subtypes.
132
- - [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional.
133
- - [`SetReadonly`](source/set-readonly.d.ts) - Create a type that makes the given keys readonly.
134
- - [`SetRequired`](source/set-required.d.ts) - Create a type that makes the given keys required.
135
- - [`SetRequiredDeep`](source/set-required-deep.d.ts) - Like `SetRequired` except it selects the keys deeply.
136
- - [`SetNonNullable`](source/set-non-nullable.d.ts) - Create a type that makes the given keys non-nullable.
143
+ - [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional, while keeping the remaining keys as is.
144
+ - [`SetReadonly`](source/set-readonly.d.ts) - Create a type that makes the given keys readonly, while keeping the remaining keys as is.
145
+ - [`SetRequired`](source/set-required.d.ts) - Create a type that makes the given keys required, while keeping the remaining keys as is.
146
+ - [`SetRequiredDeep`](source/set-required-deep.d.ts) - Create a type that makes the given keys required, with support for deeply nested key paths, while keeping the remaining keys as is.
147
+ - [`SetNonNullable`](source/set-non-nullable.d.ts) - Create a type that makes the given keys non-nullable, while keeping the remaining keys as is.
137
148
  - [`SetNonNullableDeep`](source/set-non-nullable-deep.d.ts) - Create a type that makes the specified keys non-nullable (removes `null` and `undefined`), supports deeply nested key paths, and leaves all other keys unchanged.
149
+ - [`NonNullableDeep`](source/non-nullable-deep.d.ts) - Recursively removes `null` and `undefined` from the specified type.
138
150
  - [`ValueOf`](source/value-of.d.ts) - Create a union of the given object's values, and optionally specify which keys to get the values from.
139
- - [`ConditionalKeys`](source/conditional-keys.d.ts) - Extract keys from a shape where values extend the given `Condition` type.
140
- - [`ConditionalPick`](source/conditional-pick.d.ts) - Like `Pick` except it selects properties from a shape where the values extend the given `Condition` type.
141
- - [`ConditionalPickDeep`](source/conditional-pick-deep.d.ts) - Like `ConditionalPick` except that it selects the properties deeply.
142
- - [`ConditionalExcept`](source/conditional-except.d.ts) - Like `Omit` except it removes properties from a shape where the values extend the given `Condition` type.
151
+ - [`ConditionalKeys`](source/conditional-keys.d.ts) - Extract the keys from a type where the value type of the key extends the given `Condition`.
152
+ - [`ConditionalPick`](source/conditional-pick.d.ts) - Pick keys from the shape that matches the given `Condition`.
153
+ - [`ConditionalPickDeep`](source/conditional-pick-deep.d.ts) - Pick keys recursively from the shape that matches the given condition.
154
+ - [`ConditionalExcept`](source/conditional-except.d.ts) - Exclude keys from a shape that matches the given `Condition`.
143
155
  - [`UnionToIntersection`](source/union-to-intersection.d.ts) - Convert a union type to an intersection type.
144
- - [`LiteralToPrimitive`](source/literal-to-primitive.d.ts) - Convert a [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types) to the [primitive type](source/primitive.d.ts) it belongs to.
156
+ - [`LiteralToPrimitive`](source/literal-to-primitive.d.ts) - Given a [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types) return the [primitive type](https://developer.mozilla.org/en-US/docs/Glossary/Primitive) it belongs to, or `never` if it's not a primitive.
145
157
  - [`LiteralToPrimitiveDeep`](source/literal-to-primitive-deep.d.ts) - Like `LiteralToPrimitive` except it converts literal types inside an object or array deeply.
146
158
  - [`Stringified`](source/stringified.d.ts) - Create a type with the keys of the given type changed to `string` type.
147
159
  - [`IterableElement`](source/iterable-element.d.ts) - Get the element type of an `Iterable`/`AsyncIterable`. For example, `Array`, `Set`, `Map`, generator, stream, etc.
148
- - [`Entry`](source/entry.d.ts) - Create a type that represents the type of an entry of a collection.
149
- - [`Entries`](source/entries.d.ts) - Create a type that represents the type of the entries of a collection.
160
+ - [`Entry`](source/entry.d.ts) - Create a type that describes a single key-value pair produced when calling a collection’s `entries` method.
161
+ - [`Entries`](source/entries.d.ts) - Create a type that describes the key-value pairs produced when calling a collection’s `entries` method.
150
162
  - [`SetReturnType`](source/set-return-type.d.ts) - Create a function type with a return type of your choice and the same parameters as the given function type.
151
163
  - [`SetParameterType`](source/set-parameter-type.d.ts) - Create a function that replaces some parameters with the given parameters.
152
164
  - [`Simplify`](source/simplify.d.ts) - 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.
@@ -154,21 +166,21 @@ Click the type names for complete docs.
154
166
  - [`Get`](source/get.d.ts) - Get a deeply-nested property from an object using a key path, like [Lodash's `.get()`](https://lodash.com/docs/latest#get) function.
155
167
  - [`KeyAsString`](source/key-as-string.d.ts) - Get keys of the given type as strings.
156
168
  - [`Schema`](source/schema.d.ts) - Create a deep version of another object type where property values are recursively replaced into a given value type.
157
- - [`Exact`](source/exact.d.ts) - Create a type that does not allow extra properties.
169
+ - [`Exact`](source/exact.d.ts) - Create a type that does not allow extra properties, meaning it only allows properties that are explicitly declared.
158
170
  - [`KeysOfUnion`](source/keys-of-union.d.ts) - Create a union of all keys from a given type, even those exclusive to specific union members.
159
171
  - [`OptionalKeysOf`](source/optional-keys-of.d.ts) - Extract all optional keys from the given type.
160
- - [`HasOptionalKeys`](source/has-optional-keys.d.ts) - Create a `true`/`false` type depending on whether the given type has any optional fields.
172
+ - [`HasOptionalKeys`](source/has-optional-keys.d.ts) - Returns a boolean for whether the given type has any optional fields.
161
173
  - [`RequiredKeysOf`](source/required-keys-of.d.ts) - Extract all required keys from the given type.
162
- - [`HasRequiredKeys`](source/has-required-keys.d.ts) - Create a `true`/`false` type depending on whether the given type has any required fields.
174
+ - [`HasRequiredKeys`](source/has-required-keys.d.ts) - Returns a boolean for whether the given type has any required fields.
163
175
  - [`ReadonlyKeysOf`](source/readonly-keys-of.d.ts) - Extract all readonly keys from the given type.
164
- - [`HasReadonlyKeys`](source/has-readonly-keys.d.ts) - Create a `true`/`false` type depending on whether the given type has any readonly fields.
165
- - [`WritableKeysOf`](source/writable-keys-of.d.ts) - Extract all writable (non-readonly) keys from the given type.
166
- - [`HasWritableKeys`](source/has-writable-keys.d.ts) - Create a `true`/`false` type depending on whether the given type has any writable fields.
176
+ - [`HasReadonlyKeys`](source/has-readonly-keys.d.ts) - Returns a boolean for whether the given type has any readonly fields.
177
+ - [`WritableKeysOf`](source/writable-keys-of.d.ts) - Extract all writable keys from the given type.
178
+ - [`HasWritableKeys`](source/has-writable-keys.d.ts) - Returns a boolean for whether the given type has any writable fields.
167
179
  - [`Spread`](source/spread.d.ts) - Mimic the type inferred by TypeScript when merging two objects or two arrays/tuples using the spread syntax.
168
180
  - [`IsEqual`](source/is-equal.d.ts) - Returns a boolean for whether the two given types are equal.
169
181
  - [`TaggedUnion`](source/tagged-union.d.ts) - Create a union of types that share a common discriminant property.
170
- - [`IntRange`](source/int-range.d.ts) - Generate a union of numbers (includes the start and excludes the end).
171
- - [`IntClosedRange`](source/int-closed-range.d.ts) - Generate a union of numbers (includes the start and the end).
182
+ - [`IntRange`](source/int-range.d.ts) - Generate a union of numbers between a specified start (inclusive) and end (exclusive), with an optional step.
183
+ - [`IntClosedRange`](source/int-closed-range.d.ts) - Generate a union of numbers between a specified start and end (both inclusive), with an optional step.
172
184
  - [`ArrayIndices`](source/array-indices.d.ts) - Provides valid indices for a constant array or tuple.
173
185
  - [`ArrayValues`](source/array-values.d.ts) - Provides all values for a constant array or tuple.
174
186
  - [`ArraySplice`](source/array-splice.d.ts) - Create a new array type by adding or removing elements at a specified index range in the original array.
@@ -179,7 +191,7 @@ Click the type names for complete docs.
179
191
  - [`SharedUnionFieldsDeep`](source/shared-union-fields-deep.d.ts) - Create a type with shared fields from a union of object types, deeply traversing nested structures.
180
192
  - [`AllUnionFields`](source/all-union-fields.d.ts) - Create a type with all fields from a union of object types.
181
193
  - [`DistributedOmit`](source/distributed-omit.d.ts) - Omits keys from a type, distributing the operation over a union.
182
- - [`DistributedPick`](source/distributed-pick.d.ts) - Picks keys from a type, distributing the operation over a union.
194
+ - [`DistributedPick`](source/distributed-pick.d.ts) - Pick keys from a type, distributing the operation over a union.
183
195
  - [`And`](source/and.d.ts) - Returns a boolean for whether two given types are both `true`.
184
196
  - [`Or`](source/or.d.ts) - Returns a boolean for whether either of two given types is `true`.
185
197
  - [`Xor`](source/xor.d.ts) - Returns a boolean for whether only one of two given types is `true`.
@@ -196,6 +208,7 @@ Click the type names for complete docs.
196
208
  - [`ExclusifyUnion`](source/exclusify-union.d.ts) - Ensure mutual exclusivity in object unions by adding other members’ keys as `?: never`.
197
209
  - [`Optional`](source/optional.d.ts) - Create a type that represents either the value or `undefined`, while stripping `null` from the type.
198
210
  - [`UnionMember`](source/union-member.d.ts) - Returns an arbitrary member of a union type.
211
+ - [`UnionLength`](source/union-length.d.ts) - Returns the length of a union type.
199
212
 
200
213
  ### Type Guard
201
214
 
@@ -226,7 +239,7 @@ Click the type names for complete docs.
226
239
 
227
240
  - [`Jsonify`](source/jsonify.d.ts) - Transform a type to one that is assignable to the `JsonValue` type.
228
241
  - [`Jsonifiable`](source/jsonifiable.d.ts) - Matches a value that can be losslessly converted to JSON.
229
- - [`JsonPrimitive`](source/json-value.d.ts) - Matches a JSON primitive.
242
+ - [`JsonPrimitive`](source/json-value.d.ts) - Matches any valid JSON primitive value.
230
243
  - [`JsonObject`](source/json-value.d.ts) - Matches a JSON object.
231
244
  - [`JsonArray`](source/json-value.d.ts) - Matches a JSON array.
232
245
  - [`JsonValue`](source/json-value.d.ts) - Matches any valid JSON value.
@@ -239,13 +252,13 @@ Click the type names for complete docs.
239
252
 
240
253
  - [`Promisable`](source/promisable.d.ts) - Create a type that represents either the value or the value wrapped in `PromiseLike`.
241
254
  - [`AsyncReturnType`](source/async-return-type.d.ts) - Unwrap the return type of a function that returns a `Promise`.
242
- - [`Asyncify`](source/asyncify.d.ts) - Create an async version of the given function type.
255
+ - [`Asyncify`](source/asyncify.d.ts) - Create an async version of the given function type, by boxing the return type in `Promise` while keeping the same parameter types.
243
256
 
244
257
  ### String
245
258
 
246
259
  - [`Trim`](source/trim.d.ts) - Remove leading and trailing spaces from a string.
247
260
  - [`Split`](source/split.d.ts) - Represents an array of strings split using a given character or character set.
248
- - [`Words`](source/words.d.ts) - Represents an array of strings split using a heuristic for detecting words.
261
+ - [`Words`](source/words.d.ts) - Split a string similar to Lodash's `_.words()` function.
249
262
  - [`Replace`](source/replace.d.ts) - Represents a string with some or all matches replaced by a replacement.
250
263
  - [`StringSlice`](source/string-slice.d.ts) - Returns a string slice of a given range, just like `String#slice()`.
251
264
  - [`StringRepeat`](source/string-repeat.d.ts) - Returns a new string which contains the specified number of copies of a given string, just like `String#repeat()`.
@@ -260,8 +273,8 @@ Click the type names for complete docs.
260
273
  - [`ArrayElement`](source/array-element.d.ts) - Extracts the element type of an array or tuple.
261
274
  - [`LastArrayElement`](source/last-array-element.d.ts) - Extract the type of the last element of an array.
262
275
  - [`FixedLengthArray`](source/fixed-length-array.d.ts) - Create a type that represents an array of the given type and length. The `Array` prototype methods that manipulate its length are excluded from the resulting type.
263
- - [`MultidimensionalArray`](source/multidimensional-array.d.ts) - Create a type that represents a multidimensional array of the given type and dimensions.
264
- - [`MultidimensionalReadonlyArray`](source/multidimensional-readonly-array.d.ts) - Create a type that represents a multidimensional readonly array of the given type and dimensions.
276
+ - [`MultidimensionalArray`](source/multidimensional-array.d.ts) - Create a type that represents a multidimensional array of the given type and dimension.
277
+ - [`MultidimensionalReadonlyArray`](source/multidimensional-readonly-array.d.ts) - Create a type that represents a multidimensional readonly array of the given type and dimension.
265
278
  - [`ReadonlyTuple`](source/readonly-tuple.d.ts) - Create a type that represents a read-only tuple of the given type and length.
266
279
  - [`TupleToUnion`](source/tuple-to-union.d.ts) - Convert a tuple/array into a union type of its elements.
267
280
  - [`UnionToTuple`](source/union-to-tuple.d.ts) - Convert a union type into an unordered tuple type of its elements.
@@ -287,29 +300,30 @@ Click the type names for complete docs.
287
300
  - [`NonNegativeInteger`](source/numeric.d.ts) - A non-negative (`0 <= x < ∞`) `number` that is an integer.
288
301
  - [`IsNegative`](source/numeric.d.ts) - Returns a boolean for whether the given number is a negative number.
289
302
  - [`IsFloat`](source/is-float.d.ts) - Returns a boolean for whether the given number is a float, like `1.5` or `-1.5`.
290
- - [`IsInteger`](source/is-integer.d.ts) - Returns a boolean for whether the given number is an integer, like `-5`, `1.0` or `100`.
303
+ - [`IsInteger`](source/is-integer.d.ts) - Returns a boolean for whether the given number is an integer, like `-5`, `1.0`, or `100`.
291
304
  - [`GreaterThan`](source/greater-than.d.ts) - Returns a boolean for whether a given number is greater than another number.
292
305
  - [`GreaterThanOrEqual`](source/greater-than-or-equal.d.ts) - Returns a boolean for whether a given number is greater than or equal to another number.
293
306
  - [`LessThan`](source/less-than.d.ts) - Returns a boolean for whether a given number is less than another number.
294
307
  - [`LessThanOrEqual`](source/less-than-or-equal.d.ts) - Returns a boolean for whether a given number is less than or equal to another number.
295
308
  - [`Sum`](source/sum.d.ts) - Returns the sum of two numbers.
296
309
  - [`Subtract`](source/subtract.d.ts) - Returns the difference between two numbers.
310
+ - [`Absolute`](source/absolute.d.ts) - Returns the absolute value of the specified number or bigint.
297
311
 
298
312
  ### Change case
299
313
 
300
- - [`CamelCase`](source/camel-case.d.ts) - Convert a string literal to camel-case (`fooBar`).
301
- - [`CamelCasedProperties`](source/camel-cased-properties.d.ts) - Convert object properties to camel-case (`fooBar`).
302
- - [`CamelCasedPropertiesDeep`](source/camel-cased-properties-deep.d.ts) - Convert object properties to camel-case recursively (`fooBar`).
303
- - [`KebabCase`](source/kebab-case.d.ts) - Convert a string literal to kebab-case (`foo-bar`).
304
- - [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) - Convert object properties to kebab-case (`foo-bar`).
305
- - [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) - Convert object properties to kebab-case recursively (`foo-bar`).
306
- - [`PascalCase`](source/pascal-case.d.ts) - Convert a string literal to pascal-case (`FooBar`).
307
- - [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) - Convert object properties to pascal-case (`FooBar`).
308
- - [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) - Convert object properties to pascal-case recursively (`FooBar`).
309
- - [`SnakeCase`](source/snake-case.d.ts) - Convert a string literal to snake-case (`foo_bar`).
310
- - [`SnakeCasedProperties`](source/snake-cased-properties.d.ts) - Convert object properties to snake-case (`foo_bar`).
311
- - [`SnakeCasedPropertiesDeep`](source/snake-cased-properties-deep.d.ts) - Convert object properties to snake-case recursively (`foo_bar`).
312
- - [`ScreamingSnakeCase`](source/screaming-snake-case.d.ts) - Convert a string literal to screaming-snake-case (`FOO_BAR`).
314
+ - [`CamelCase`](source/camel-case.d.ts) - Convert a string literal to camel-case.
315
+ - [`CamelCasedProperties`](source/camel-cased-properties.d.ts) - Convert top-level object properties to camel case.
316
+ - [`CamelCasedPropertiesDeep`](source/camel-cased-properties-deep.d.ts) - Convert object properties to camel case recursively.
317
+ - [`KebabCase`](source/kebab-case.d.ts) - Convert a string literal to kebab-case.
318
+ - [`KebabCasedProperties`](source/kebab-cased-properties.d.ts) - Convert top-level object properties to kebab case.
319
+ - [`KebabCasedPropertiesDeep`](source/kebab-cased-properties-deep.d.ts) - Convert object properties to kebab case recursively.
320
+ - [`PascalCase`](source/pascal-case.d.ts) - Convert a string literal to pascal-case.
321
+ - [`PascalCasedProperties`](source/pascal-cased-properties.d.ts) - Convert top-level object properties to pascal case.
322
+ - [`PascalCasedPropertiesDeep`](source/pascal-cased-properties-deep.d.ts) - Convert object properties to pascal case recursively.
323
+ - [`SnakeCase`](source/snake-case.d.ts) - Convert a string literal to snake-case.
324
+ - [`SnakeCasedProperties`](source/snake-cased-properties.d.ts) - Convert top-level object properties to snake case.
325
+ - [`SnakeCasedPropertiesDeep`](source/snake-cased-properties-deep.d.ts) - Convert object properties to snake case recursively.
326
+ - [`ScreamingSnakeCase`](source/screaming-snake-case.d.ts) - Convert a string literal to screaming-snake-case.
313
327
  - [`DelimiterCase`](source/delimiter-case.d.ts) - Convert a string literal to a custom string delimiter casing.
314
328
  - [`DelimiterCasedProperties`](source/delimiter-cased-properties.d.ts) - Convert object properties to a custom string delimiter casing.
315
329
  - [`DelimiterCasedPropertiesDeep`](source/delimiter-cased-properties-deep.d.ts) - Convert object properties to a custom string delimiter casing recursively.
@@ -317,7 +331,7 @@ Click the type names for complete docs.
317
331
  ### Miscellaneous
318
332
 
319
333
  - [`GlobalThis`](source/global-this.d.ts) - Declare locally scoped properties on `globalThis`.
320
- - [`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).
334
+ - [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
321
335
  - [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
322
336
 
323
337
  ### Improved built-in
@@ -370,6 +384,7 @@ Click the type names for complete docs.
370
384
 
371
385
  ### Extending existing types
372
386
 
387
+ <!-- eslint-disable-next-line type-fest/readme-jsdoc-sync -->
373
388
  - [`PackageJson`](source/package-json.d.ts) - There are a lot of tools that place extra configurations inside the `package.json` file. You can extend `PackageJson` to support these additional configurations.
374
389
  <details>
375
390
  <summary>
@@ -0,0 +1,52 @@
1
+ import type {StringToNumber} from './internal/string.d.ts';
2
+
3
+ /**
4
+ Returns the absolute value of the specified number or bigint.
5
+
6
+ @example
7
+ ```
8
+ import type {Absolute} from 'type-fest';
9
+
10
+ type A = Absolute<-1>;
11
+ //=> 1
12
+
13
+ type B = Absolute<1>;
14
+ //=> 1
15
+
16
+ type C = Absolute<0>;
17
+ //=> 0
18
+
19
+ type D = Absolute<-1.025>;
20
+ //=> 1.025
21
+
22
+ type E = Absolute<-9999n>;
23
+ //=> 9999n
24
+ ```
25
+
26
+ Returns back the same type if the input is not a literal type.
27
+
28
+ @example
29
+ ```
30
+ import type {Absolute} from 'type-fest';
31
+
32
+ type A = Absolute<number>;
33
+ //=> number
34
+
35
+ type B = Absolute<bigint>;
36
+ //=> bigint
37
+
38
+ type C = Absolute<number | bigint>;
39
+ //=> number | bigint
40
+ ```
41
+
42
+ @category Numeric
43
+ */
44
+ export type Absolute<N extends number | bigint> = N extends bigint // Also, distributes `N`
45
+ ? `${N}` extends `-${infer Magnitude extends bigint}`
46
+ ? Magnitude
47
+ : N
48
+ : `${N}` extends `-${infer Magnitude}` // This doesn't use the `extends number` constraint approach because that fails with the `-Infinity` case
49
+ ? StringToNumber<Magnitude>
50
+ : N;
51
+
52
+ export {};
@@ -69,23 +69,23 @@ function displayPetInfoWithAllUnionFields(petInfo: AllUnionFields<Cat | Dog>) {
69
69
  @category Union
70
70
  */
71
71
  export type AllUnionFields<Union> =
72
- Extract<Union, NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | UnknownArray> extends infer SkippedMembers
73
- ? Exclude<Union, SkippedMembers> extends infer RelevantMembers
74
- ?
75
- | SkippedMembers
76
- | Simplify<
77
- // Include fields that are common in all union members
78
- SharedUnionFields<RelevantMembers> &
79
- // Include readonly fields present in any union member
80
- {
81
- readonly [P in ReadonlyKeysOfUnion<RelevantMembers>]?: ValueOfUnion<RelevantMembers, P & KeysOfUnion<RelevantMembers>>
82
- } &
83
- // Include remaining fields that are neither common nor readonly
84
- {
85
- [P in Exclude<KeysOfUnion<RelevantMembers>, ReadonlyKeysOfUnion<RelevantMembers> | keyof RelevantMembers>]?: ValueOfUnion<RelevantMembers, P>
86
- }
87
- >
88
- : never
89
- : never;
72
+ Extract<Union, NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | UnknownArray> extends infer SkippedMembers
73
+ ? Exclude<Union, SkippedMembers> extends infer RelevantMembers
74
+ ? // eslint-disable-line @stylistic/operator-linebreak
75
+ | SkippedMembers
76
+ | Simplify<
77
+ // Include fields that are common in all union members
78
+ SharedUnionFields<RelevantMembers>
79
+ // Include readonly fields present in any union member
80
+ & {
81
+ readonly [P in ReadonlyKeysOfUnion<RelevantMembers>]?: ValueOfUnion<RelevantMembers, P & KeysOfUnion<RelevantMembers>>
82
+ }
83
+ // Include remaining fields that are neither common nor readonly
84
+ & {
85
+ [P in Exclude<KeysOfUnion<RelevantMembers>, ReadonlyKeysOfUnion<RelevantMembers> | keyof RelevantMembers>]?: ValueOfUnion<RelevantMembers, P>
86
+ }
87
+ >
88
+ : never
89
+ : never;
90
90
 
91
91
  export {};
package/source/and.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type {AndAll} from './and-all.d.ts';
2
2
 
3
3
  /**
4
- Returns a boolean for whether two given types are both true.
4
+ Returns a boolean for whether two given types are both `true`.
5
5
 
6
6
  Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
7
7
 
@@ -8,13 +8,13 @@ import type {TupleOf} from './tuple-of.d.ts';
8
8
  The implementation of `SplitArrayByIndex` for fixed length arrays.
9
9
  */
10
10
  type SplitFixedArrayByIndex<T extends UnknownArray, SplitIndex extends number> =
11
- SplitIndex extends 0
12
- ? [[], T]
13
- : T extends readonly [...TupleOf<SplitIndex>, ...infer V]
14
- ? T extends readonly [...infer U, ...V]
15
- ? [U, V]
16
- : [never, never]
17
- : [never, never];
11
+ SplitIndex extends 0
12
+ ? [[], T]
13
+ : T extends readonly [...TupleOf<SplitIndex>, ...infer V]
14
+ ? T extends readonly [...infer U, ...V]
15
+ ? [U, V]
16
+ : [never, never]
17
+ : [never, never];
18
18
 
19
19
  /**
20
20
  The implementation of `SplitArrayByIndex` for variable length arrays.
@@ -26,23 +26,23 @@ type SplitVariableArrayByIndex<T extends UnknownArray,
26
26
  ? TupleOf<GreaterThanOrEqual<T1, 0> extends true ? T1 : number, VariablePartOfArray<T>[number]>
27
27
  : [],
28
28
  > =
29
- SplitIndex extends 0
30
- ? [[], T]
31
- : GreaterThanOrEqual<StaticPartOfArray<T>['length'], SplitIndex> extends true
32
- ? [
33
- SplitFixedArrayByIndex<StaticPartOfArray<T>, SplitIndex>[0],
34
- [
35
- ...SplitFixedArrayByIndex<StaticPartOfArray<T>, SplitIndex>[1],
36
- ...VariablePartOfArray<T>,
37
- ],
38
- ]
39
- : [
40
- [
41
- ...StaticPartOfArray<T>,
42
- ...(T2 extends UnknownArray ? T2 : []),
43
- ],
44
- VariablePartOfArray<T>,
45
- ];
29
+ SplitIndex extends 0
30
+ ? [[], T]
31
+ : GreaterThanOrEqual<StaticPartOfArray<T>['length'], SplitIndex> extends true
32
+ ? [
33
+ SplitFixedArrayByIndex<StaticPartOfArray<T>, SplitIndex>[0],
34
+ [
35
+ ...SplitFixedArrayByIndex<StaticPartOfArray<T>, SplitIndex>[1],
36
+ ...VariablePartOfArray<T>,
37
+ ],
38
+ ]
39
+ : [
40
+ [
41
+ ...StaticPartOfArray<T>,
42
+ ...(T2 extends UnknownArray ? T2 : []),
43
+ ],
44
+ VariablePartOfArray<T>,
45
+ ];
46
46
 
47
47
  /**
48
48
  Split the given array `T` by the given `SplitIndex`.
@@ -1,5 +1,5 @@
1
1
  import type {ApplyDefaultOptions} from './internal/index.d.ts';
2
- import type {Words, WordsOptions} from './words.d.ts';
2
+ import type {_DefaultWordsOptions, Words, WordsOptions} from './words.d.ts';
3
3
 
4
4
  /**
5
5
  CamelCase options.
@@ -13,13 +13,39 @@ export type CamelCaseOptions = WordsOptions & {
13
13
  @default false
14
14
  */
15
15
  preserveConsecutiveUppercase?: boolean;
16
+
17
+ /**
18
+ Whether to preserve leading underscores.
19
+
20
+ This matches the behavior of the [`camelcase`](https://github.com/sindresorhus/camelcase) package v9+.
21
+
22
+ @default false
23
+ */
24
+ preserveLeadingUnderscores?: boolean;
16
25
  };
17
26
 
18
- export type _DefaultCamelCaseOptions = {
19
- splitOnNumbers: true;
27
+ export type _DefaultCamelCaseOptions = _DefaultWordsOptions & {
20
28
  preserveConsecutiveUppercase: false;
29
+ preserveLeadingUnderscores: false;
21
30
  };
22
31
 
32
+ /**
33
+ Extract leading underscores from a string.
34
+
35
+ @example
36
+ ```
37
+ type A = LeadingUnderscores<'__foo_bar'>;
38
+ //=> '__'
39
+
40
+ type B = LeadingUnderscores<'foo_bar'>;
41
+ //=> ''
42
+ ```
43
+ */
44
+ type LeadingUnderscores<Type extends string, Underscores extends string = ''> =
45
+ Type extends `_${infer Rest}`
46
+ ? LeadingUnderscores<Rest, `_${Underscores}`>
47
+ : Underscores;
48
+
23
49
  /**
24
50
  Convert an array of words to camel-case.
25
51
  */
@@ -43,6 +69,8 @@ This can be useful when, for example, converting some kebab-cased command-line f
43
69
 
44
70
  By default, consecutive uppercase letter are preserved. See {@link CamelCaseOptions.preserveConsecutiveUppercase preserveConsecutiveUppercase} option to change this behaviour.
45
71
 
72
+ Use the `preserveLeadingUnderscores` option to retain leading underscores, matching the runtime behavior of [`camelcase`](https://github.com/sindresorhus/camelcase) v9+.
73
+
46
74
  @example
47
75
  ```
48
76
  import type {CamelCase} from 'type-fest';
@@ -51,6 +79,8 @@ import type {CamelCase} from 'type-fest';
51
79
 
52
80
  const someVariable: CamelCase<'foo-bar'> = 'fooBar';
53
81
  const preserveConsecutiveUppercase: CamelCase<'foo-BAR-baz', {preserveConsecutiveUppercase: true}> = 'fooBARBaz';
82
+ const splitOnPunctuation: CamelCase<'foo-bar:BAZ', {splitOnPunctuation: true}> = 'fooBarBaz';
83
+ const preserveLeadingUnderscores: CamelCase<'_foo_bar', {preserveLeadingUnderscores: true}> = '_fooBar';
54
84
 
55
85
  // Advanced
56
86
 
@@ -83,10 +113,13 @@ const dbResult: CamelCasedProperties<RawOptions> = {
83
113
  export type CamelCase<Type, Options extends CamelCaseOptions = {}> = Type extends string
84
114
  ? string extends Type
85
115
  ? Type
86
- : Uncapitalize<CamelCaseFromArray<
116
+ : `${Options['preserveLeadingUnderscores'] extends true
117
+ ? LeadingUnderscores<Type>
118
+ : ''
119
+ }${Uncapitalize<CamelCaseFromArray<
87
120
  Words<Type extends Uppercase<Type> ? Lowercase<Type> : Type, Options>,
88
121
  ApplyDefaultOptions<CamelCaseOptions, _DefaultCamelCaseOptions, Options>
89
- >>
122
+ >>}`
90
123
  : Type;
91
124
 
92
125
  export {};
@@ -48,6 +48,13 @@ const preserveConsecutiveUppercase: CamelCasedPropertiesDeep<{fooBAR: {fooBARBiz
48
48
  }],
49
49
  },
50
50
  };
51
+
52
+ const splitOnPunctuation: CamelCasedPropertiesDeep<{'user@info': {'user::id': number; 'user::name': string}}, {splitOnPunctuation: true}> = {
53
+ userInfo: {
54
+ userId: 1,
55
+ userName: 'Tom',
56
+ },
57
+ };
51
58
  ```
52
59
 
53
60
  @category Change case
@@ -86,11 +93,11 @@ type CamelCasedPropertiesArrayDeep<
86
93
  ? [_CamelCasedPropertiesDeep<U, Options>, ..._CamelCasedPropertiesDeep<V, Options>]
87
94
  : Value extends readonly [infer U, ...infer V]
88
95
  ? readonly [_CamelCasedPropertiesDeep<U, Options>, ..._CamelCasedPropertiesDeep<V, Options>]
89
- : // Leading spread array
90
- Value extends readonly [...infer U, infer V]
96
+ // Leading spread array
97
+ : Value extends readonly [...infer U, infer V]
91
98
  ? [..._CamelCasedPropertiesDeep<U, Options>, _CamelCasedPropertiesDeep<V, Options>]
92
- : // Array
93
- Value extends Array<infer U>
99
+ // Array
100
+ : Value extends Array<infer U>
94
101
  ? Array<_CamelCasedPropertiesDeep<U, Options>>
95
102
  : Value extends ReadonlyArray<infer U>
96
103
  ? ReadonlyArray<_CamelCasedPropertiesDeep<U, Options>>
@@ -2,7 +2,7 @@ import type {CamelCase, CamelCaseOptions, _DefaultCamelCaseOptions} from './came
2
2
  import type {ApplyDefaultOptions} from './internal/index.d.ts';
3
3
 
4
4
  /**
5
- Convert object properties to camel case but not recursively.
5
+ Convert top-level object properties to camel case.
6
6
 
7
7
  This can be useful when, for example, converting some API types from a different style.
8
8
 
@@ -26,6 +26,10 @@ const result: CamelCasedProperties<User> = {
26
26
  const preserveConsecutiveUppercase: CamelCasedProperties<{fooBAR: string}, {preserveConsecutiveUppercase: true}> = {
27
27
  fooBAR: 'string',
28
28
  };
29
+
30
+ const splitOnPunctuation: CamelCasedProperties<{'foo::bar': string}, {splitOnPunctuation: true}> = {
31
+ fooBar: 'string',
32
+ };
29
33
  ```
30
34
 
31
35
  @category Change case
@@ -38,6 +38,7 @@ import type {DelimiterCase} from 'type-fest';
38
38
 
39
39
  const someVariable: DelimiterCase<'fooBar', '#'> = 'foo#bar';
40
40
  const someVariableNoSplitOnNumbers: DelimiterCase<'p2pNetwork', '#', {splitOnNumbers: false}> = 'p2p#network';
41
+ const someVariableWithPunctuation: DelimiterCase<'div.card::after', '#', {splitOnPunctuation: true}> = 'div#card#after';
41
42
 
42
43
  // Advanced
43
44