Skip to content

v2.0.0

Choose a tag to compare

@sindresorhus sindresorhus released this 05 Nov 05:20
· 5 commits to main since this release

Breaking

  • Require Node.js 22 0a333be
  • isFinite(), isInteger(), and isSafeInteger() now only narrow numeric literal types 35b9c24
    • A broad number now gives a plain boolean. Before, one of the branches was typed never: the else branch for isFinite(), and the if branch for isInteger() and isSafeInteger().
    • .filter(isFinite) no longer narrows. To filter a union of numeric literals, use .filter(value => isFinite(value)).
  • objectFromEntries(): If any as const entry has a union or widened key (for example, [condition ? 'a' : 'b', 1]), every key of the result is now optional 0a127b7
    • Before, all keys were typed as required, even though only one member of the union key was written.
  • objectMapValues(): The strict option is deprecated and has no effect 0a127b7
    • The callback is always typed from the object's own keys and values.
  • assertError() now rejects objects that fake the Error brand with Symbol.toStringTag 64c3ed0

New types

Improvements

Fixes

  • Fix isEmpty() narrowing a non-tuple array to never 35b9c24
  • Fix arrayIncludes() and setHas() narrowing the else branch to never when the item already has the element type 6b697de
  • Fix objectKeys(), objectValues(), and objectEntries() including Array.prototype members for tuples, typed arrays, and Buffer 0a127b7
  • Fix not() narrowing a branch to never for an unknown value 35b9c24
  • Fix objectHasOwn() throwing for null and undefined 0a127b7
  • Fix objectHasIn() and keyIn() throwing for primitives 0a127b7 35b9c24
  • Fix objectHasIn(), objectHasOwn(), and keyIn() narrowing a branch to never for index signatures and widened keys. They now return a plain boolean there 0a127b7 35b9c24
  • Fix isPropertyDefined() and isPropertyPresent() dropping readonly modifiers and union members that do not declare the key 35b9c24
  • Fix arrayAt() types for negative indices other than -1 and for fractional indices on tuples 6b697de
  • Fix the type guards throwing for revoked proxies 0a127b7 35b9c24

v1.3.0...v2.0.0