Repository navigation
Releases
Releases · sindresorhus/type-fest
v6.0.3
v6.0.2
Exact: Fix slow type-checking with an index signature and a generic input value 22d031b
v6.0.1
v6.0.0
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: truein your tsconfig 82f2b44- The types no longer have compatibility logic for
exactOptionalPropertyTypes: false. Disabling it is unsupported.
- The types no longer have compatibility logic for
- Reminder:
type-festrequiresstrict, which is the default since TypeScript 6. Do not set it tofalse. - Remove the deprecated
IfAny,IfNever,IfUnknown,IfNull, andIfEmptyObjecttypes. UseIfwith the matchingIs*type. 6fc1861 - Remove the deprecated
ReadonlyTupletype. UseReadonly<TupleOf<Length, Element>>. 6fc1861 CamelCase,PascalCase,KebabCase,SnakeCase,ScreamingSnakeCase,DelimiterCase,Words, and their*CasedProperties/*CasedPropertiesDeeptypes: EnablesplitOnPunctuationby default. ebc42e5KebabCase<'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*CasedPropertiestypes): DisablesplitOnNumbersby default 976bd26CamelCase<'p2p_network'>is now'p2pNetwork'(was'p2PNetwork'). The other case types already usedfalse.
CamelCase/PascalCase(and their*CasedPropertiestypes): EnablepreserveLeadingUnderscoresby default 8144ba1CamelCase<'_id'>is now'_id'(was'id'). This matches thecamelcasepackage.PascalCase<'_foo_bar'>is now'_FooBar'(was'FooBar').
Words: WithsplitOnPunctuation: false, punctuation now stays inside the word:Words<'hello:world', {splitOnPunctuation: false}>is['hello:world'](was['hello', ':world']) 9f2ad66PartialDeep: EnablerecurseIntoArraysby default. ab0e23d- The elements of arrays and tuples are now deeply partial, and the fixed elements of tuples become optional.
allowUndefinedInNonTupleArrays: truenow works alone. Before, it also neededrecurseIntoArrays: true.
PartialOnUndefinedDeep: EnablerecurseIntoArraysby default 939abe3ExtendsStrict: EnablestrictAnyby default, soExtendsStrict<any, number>is nowfalse. Pass{strictAny: false}to get the old behavior. b2f7ed4Split: Rename thestrictLiteralChecksoption tostrictbc38ddbStringToArray: Replace themapNonLiteralsDirectlyoption withstrict, which has the opposite meaning.{mapNonLiteralsDirectly: true}is now{strict: false}. b61e528- The old option names now give a compiler error.
ReadonlyDeep: ConvertDateto the newReadonlyDatetype, which has noset*methods.WritableDeepconverts it back toDate. c533251TsConfigJson: Remove the options and values that TypeScript 5.5 removed and that TypeScript 6.0 deprecated. 393c093 0716fa8 4e54420 65b2db8- Predicates now return
falseinstead ofneverwhen an input isnever9ec1de5- This applies to
IsEmptyObject,IsFloat,IsInteger,IsNegative,GreaterThan,GreaterThanOrEqual,LessThan,LessThanOrEqual,Includes,IsOptionalKeyOf,IsRequiredKeyOf,IsReadonlyKeyOf, andIsWritableKeyOf. - If you checked the result with
IsNeveror[Result] extends [never], check forfalseinstead.
- This applies to
IsNull/IsUndefined: Returnfalseforanyandnever(wastrue) 349271e 750177a 65fc2ebIsOptionalKeyOf/IsRequiredKeyOf/IsReadonlyKeyOf/IsWritableKeyOf: Read a literal key of an index signature like the index signature, and read ananyobject likeRecord<PropertyKey, any>62df5d9 5a2e786IsOptionalKeyOf<Record<string, number>, 'x'>is nowtrue(wasfalse), andIsRequiredKeyOfis nowfalse.IsReadonlyKeyOf<{readonly [key: string]: number}, 'x'>is nowtrue(wasfalse).- With an
anyobject, the result wasnever. Now a literal key is optional and writable, soIsOptionalKeyOf<any, 'a'>andIsWritableKeyOf<any, 'a'>aretrue, andIsRequiredKeyOf<any, 'a'>andIsReadonlyKeyOf<any, 'a'>arefalse. Astring,number, orsymbolkey is required, and ananykey givesboolean.
FixedLengthArray: Returnneverfor a non-literal length, likenumber. Use a normal array type for an unknown length. 88281feFinite/NonNegative: Returnneverfor the widenumbertype (wasnumber) 23e295fNonNegative/Negative: RejectInfinityand-Infinity(for example1e999) 608026dJsonifiable: Reject values typedobject, because they can contain anything 92aba94ConditionalPickDeep: Matchanyandnevervalues likeConditionalKeys. Anevervalue is no longer picked, and ananyvalue is now picked. 02aef94- Other result changes that you can see in existing code:
Simplify: Keep functions, class constructors, and branded primitives as is.Simplify<() => void>was{}. 28b9f8e 7d0a323Merge: Keep the call signatures of the input 166b209- The deep types (
PartialDeep,ReadonlyDeep,RequiredDeep, and others) no longer recurse into DOM nodes, likeHTMLElemente379753 Entries/Entry: Pair each key with its own value.Entry<{a: 1; b: 'x'}>is now['a', 1] | ['b', 'x'](was['a' | 'b', 1 | 'x']). 34d036fValueOf: Read the values of every union member.ValueOf<{a: 1} | {b: 2}>is now1 | 2(wasnever). 6a0de70 1a2e90aGet: Returnundefinedfor the union members that do not have the key.Get<{a: 1} | {b: 2}, 'a'>is now1 | undefined(wasunknown). cc955bdLiteralToPrimitiveDeep: Keep tuples as tuples.[1]becomes[number](wasnumber[]). 8173c2cLiteralToPrimitive: Returnanyforany65fc2ebMultidimensionalArray/MultidimensionalReadonlyArray: Allow leaf values at all levels when the dimension is not known 762b656RemovePrefix/RemoveSuffix: Returnstringwhen a non-literal input cannot contain the affix.RemovePrefix<`user_${string}`, 'admin_'>is nowstring(was`user_${string}`). b8c6ef2 1fbd1d2IsEmptyObject: Returnfalseforobject(wastrue) and forany(wasboolean) 43c237d 9ec1de5HasRequiredKeys: Returnfalsefor index signatures, arrays without required elements, andany(wastrue) 1c184e6IsFloat: Returnbooleanforany(wasfalse) cdf0edeAsyncify: Keep the return type of each function in a union 1b374deSingleKeyObject: Returnneverforboolean(wasboolean), and return bro...
v5.10.0
v5.9.0
New types
Improvements
SharedUnionFieldsDeep: Ensure it doesn't distribute processed union over mapped type (#1509) 07a04deTypedArray: AddFloat16Array(#1495) ca27cce
Fixes
Writable: Fix behavior with index signatures (#1470) 48ddc4bJsonify: Fix optional properties leakingundefinedinto the key set (#1484) 5339fb3IsLiteral*: Fix behavior with unions (#1482) 3425142
v5.8.0
New types
StringToArray(#1457) b773e84StringLength(#1457) b773e84StringToNumber(#1446) 2a14c2dExtractExactly(#1445) 26f3c99
Improvements
Fixes
LastArrayElement: Fix handling of tuples with optional elements (#1461) 8e5c69aSchema: Fix incorrect handling ofanyandunknownfields (#1459) 82ccfc3StringRepeat: Fix behavior with extremely large/small counts (#1455) 441ac27
v5.7.0
New types
Improvements
ExtendsStrict: AdddistributiveUnions,strictNever&strictAnyoptions (#1408) 9ea810bTupleOf: Improve implementation (#1441) 391e1bb
Fixes
RemovePrefix: Fix: Remove incorrect optimization and always fallback tostringfor non-literal prefixes (#1438) 9f35398DelimiterCase: Fix behavior with non-single character delimiters (#1424) 9b36590RemovePrefix: Fixanyprefix behavior in non-strict mode (#1423) c49cb75DelimiterCase: Fix behavior with union delimiters (#1422) 96172c0ApplyDefaultOptions: Fix behavior with generic instantiations &anyvalues (#1411) c46020dApplyDefaultOptions: Fix behavior with explicitundefined(#1407) 60bfd3f
v5.6.0
New types
Improvements
- Add
splitOnPunctuationoption toCamelCase/PascalCase/KebabCase/SnakeCase(#1394) 852d016 CamelCase: AddpreserveLeadingUnderscoresoption (#1404) 5ca6564TsConfigJson: Add TypeScript 6.0 fields (#1406) ac4861dUnionToTuple: Fix behavior with large unions (#1405) 651f7ea
v5.5.0
New types
Optional(#1374) 9b52980ExcludeExactly(#1349) 0f923d0ArrayLength(#1344) 59bd056UnionMember(#1368) 878b6dfSomeExtend(#1380) bbce298AndAll(#1383) 94aa3f8OrAll(#1378) 4c42d89
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) 0f923d0ConditionalPickDeep: Fix returning{}instead ofneverwhen no keys match (#1360) 6af847aConditionalPick: Fix returning{}instead ofneverwhen no keys match (#1359) 3995003GreaterThan/LessThan/GreaterThanOrEqual/LessThanOrEqual: Fix behavior with thenumbertype (#1363) cfea505