Skip to content

Releases

v6.0.3

Choose a tag to compare

@sindresorhus sindresorhus released this 19 Nov 07:45
  • Exact: Preserve readonly index signatures 2a0893b
  • Exact: Accept number keys for a string index signature 5c0e1cc
  • Exact: Fix slow type-checking and false rejections with an index signature and a generic input value 56b6285

v6.0.2...v6.0.3

v6.0.2

Choose a tag to compare

@sindresorhus sindresorhus released this 18 Nov 17:16
  • Exact: Fix slow type-checking with an index signature and a generic input value 22d031b

v6.0.1...v6.0.2

v6.0.1

Choose a tag to compare

@sindresorhus sindresorhus released this 17 Nov 06:51
  • SetOptional, SetRequired, SetReadonly: Fix out-of-memory type-checking with generic keys 80b7baa
  • ObjectMerge: Treat NaN keys as numeric 916ed24

v6.0.0...v6.0.1

v6.0.0

Choose a tag to compare

@sindresorhus sindresorhus released this 16 Nov 09:17

Summary

This is a huge release! 120 new types. All open issues resolved. A huge number of performance and correctness fixes.

Breaking

  • Require TypeScript 6 9ec2593
  • Require Node.js 22 9ec2593
  • Require exactOptionalPropertyTypes: true in your tsconfig 82f2b44
    • The types no longer have compatibility logic for exactOptionalPropertyTypes: false. Disabling it is unsupported.
  • Reminder: type-fest requires strict, which is the default since TypeScript 6. Do not set it to false.
  • Remove the deprecated IfAny, IfNever, IfUnknown, IfNull, and IfEmptyObject types. Use If with the matching Is* type. 6fc1861
  • Remove the deprecated ReadonlyTuple type. Use Readonly<TupleOf<Length, Element>>. 6fc1861
  • CamelCase, PascalCase, KebabCase, SnakeCase, ScreamingSnakeCase, DelimiterCase, Words, and their *CasedProperties / *CasedPropertiesDeep types: Enable splitOnPunctuation by default. ebc42e5
    • KebabCase<'div.card::after'> is now 'div-card-after' (was 'div.card::after').
    • A leading $ is now removed: CamelCase<'$foo'> is 'foo'.
  • CamelCase / PascalCase (and their *CasedProperties types): Disable splitOnNumbers by default 976bd26
    • CamelCase<'p2p_network'> is now 'p2pNetwork' (was 'p2PNetwork'). The other case types already used false.
  • CamelCase / PascalCase (and their *CasedProperties types): Enable preserveLeadingUnderscores by default 8144ba1
    • CamelCase<'_id'> is now '_id' (was 'id'). This matches the camelcase package.
    • PascalCase<'_foo_bar'> is now '_FooBar' (was 'FooBar').
  • Words: With splitOnPunctuation: false, punctuation now stays inside the word: Words<'hello:world', {splitOnPunctuation: false}> is ['hello:world'] (was ['hello', ':world']) 9f2ad66
  • PartialDeep: Enable recurseIntoArrays by default. ab0e23d
    • The elements of arrays and tuples are now deeply partial, and the fixed elements of tuples become optional.
    • allowUndefinedInNonTupleArrays: true now works alone. Before, it also needed recurseIntoArrays: true.
  • PartialOnUndefinedDeep: Enable recurseIntoArrays by default 939abe3
  • ExtendsStrict: Enable strictAny by default, so ExtendsStrict<any, number> is now false. Pass {strictAny: false} to get the old behavior. b2f7ed4
  • Split: Rename the strictLiteralChecks option to strict bc38ddb
  • StringToArray: Replace the mapNonLiteralsDirectly option with strict, which has the opposite meaning. {mapNonLiteralsDirectly: true} is now {strict: false}. b61e528
    • The old option names now give a compiler error.
  • ReadonlyDeep: Convert Date to the new ReadonlyDate type, which has no set* methods. WritableDeep converts it back to Date. c533251
  • TsConfigJson: Remove the options and values that TypeScript 5.5 removed and that TypeScript 6.0 deprecated. 393c093 0716fa8 4e54420 65b2db8
  • Predicates now return false instead of never when an input is never 9ec1de5
    • This applies to IsEmptyObject, IsFloat, IsInteger, IsNegative, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, Includes, IsOptionalKeyOf, IsRequiredKeyOf, IsReadonlyKeyOf, and IsWritableKeyOf.
    • If you checked the result with IsNever or [Result] extends [never], check for false instead.
  • IsNull / IsUndefined: Return false for any and never (was true) 349271e 750177a 65fc2eb
  • IsOptionalKeyOf / IsRequiredKeyOf / IsReadonlyKeyOf / IsWritableKeyOf: Read a literal key of an index signature like the index signature, and read an any object like Record<PropertyKey, any> 62df5d9 5a2e786
    • IsOptionalKeyOf<Record<string, number>, 'x'> is now true (was false), and IsRequiredKeyOf is now false.
    • IsReadonlyKeyOf<{readonly [key: string]: number}, 'x'> is now true (was false).
    • With an any object, the result was never. Now a literal key is optional and writable, so IsOptionalKeyOf<any, 'a'> and IsWritableKeyOf<any, 'a'> are true, and IsRequiredKeyOf<any, 'a'> and IsReadonlyKeyOf<any, 'a'> are false. A string, number, or symbol key is required, and an any key gives boolean.
  • FixedLengthArray: Return never for a non-literal length, like number. Use a normal array type for an unknown length. 88281fe
  • Finite / NonNegative: Return never for the wide number type (was number) 23e295f
  • NonNegative / Negative: Reject Infinity and -Infinity (for example 1e999) 608026d
  • Jsonifiable: Reject values typed object, because they can contain anything 92aba94
  • ConditionalPickDeep: Match any and never values like ConditionalKeys. A never value is no longer picked, and an any value is now picked. 02aef94
  • Other result changes that you can see in existing code:
Read more

v5.10.0

Choose a tag to compare

@sindresorhus sindresorhus released this 17 Sep 09:10

v5.9.0...v5.10.0

v5.9.0

Choose a tag to compare

@sindresorhus sindresorhus released this 30 Aug 23:59

New types

Improvements

  • SharedUnionFieldsDeep: Ensure it doesn't distribute processed union over mapped type (#1509) 07a04de
  • TypedArray: Add Float16Array (#1495) ca27cce

Fixes

  • Writable: Fix behavior with index signatures (#1470) 48ddc4b
  • Jsonify: Fix optional properties leaking undefined into the key set (#1484) 5339fb3
  • IsLiteral*: Fix behavior with unions (#1482) 3425142

v5.8.0...v5.9.0

v5.8.0

Choose a tag to compare

@sindresorhus sindresorhus released this 04 Jul 23:03

New types

Improvements

  • StringRepeat: Add support for generating really long strings (#1447) 1b7eed6

Fixes

  • LastArrayElement: Fix handling of tuples with optional elements (#1461) 8e5c69a
  • Schema: Fix incorrect handling of any and unknown fields (#1459) 82ccfc3
  • StringRepeat: Fix behavior with extremely large/small counts (#1455) 441ac27

v5.7.0...v5.8.0

v5.7.0

Choose a tag to compare

@sindresorhus sindresorhus released this 31 May 19:29

New types

Improvements

  • ExtendsStrict: Add distributiveUnions, strictNever & strictAny options (#1408) 9ea810b
  • TupleOf: Improve implementation (#1441) 391e1bb

Fixes

  • RemovePrefix: Fix: Remove incorrect optimization and always fallback to string for non-literal prefixes (#1438) 9f35398
  • DelimiterCase: Fix behavior with non-single character delimiters (#1424) 9b36590
  • RemovePrefix: Fix any prefix behavior in non-strict mode (#1423) c49cb75
  • DelimiterCase: Fix behavior with union delimiters (#1422) 96172c0
  • ApplyDefaultOptions: Fix behavior with generic instantiations & any values (#1411) c46020d
  • ApplyDefaultOptions: Fix behavior with explicit undefined (#1407) 60bfd3f

v5.6.0...v5.7.0

v5.6.0

Choose a tag to compare

@sindresorhus sindresorhus released this 17 Apr 08:34

New types

Improvements

  • Add splitOnPunctuation option to CamelCase / PascalCase / KebabCase / SnakeCase (#1394) 852d016
  • CamelCase: Add preserveLeadingUnderscores option (#1404) 5ca6564
  • TsConfigJson: Add TypeScript 6.0 fields (#1406) ac4861d
  • UnionToTuple: Fix behavior with large unions (#1405) 651f7ea

v5.5.0...v5.6.0

v5.5.0

Choose a tag to compare

@sindresorhus sindresorhus released this 19 Mar 08:13

New types

Improvements

  • Add function parameter constraint examples to numeric comparison types (#1357) 24be93d
  • UnionToTuple: Fix behavior when a union member is a supertype of another (#1349) 0f923d0
  • ConditionalPickDeep: Fix returning {} instead of never when no keys match (#1360) 6af847a
  • ConditionalPick: Fix returning {} instead of never when no keys match (#1359) 3995003
  • GreaterThan / LessThan / GreaterThanOrEqual / LessThanOrEqual: Fix behavior with the number type (#1363) cfea505

v5.4.4...v5.5.0