Skip to content

Releases: clickbar/dot-diver

1.0.7

22 Aug 19:53
59a98ae
Compare
Choose a tag to compare

What's Changed

  • fix(get): reactivity on proxy objects by @saibotk in #36

Full Changelog: 1.0.6...1.0.7

2.0.0

18 Aug 05:24
00dc0a8
Compare
Choose a tag to compare

Features

Support paths up to a depth of 40 (limited by TypeScript's recursion depth) by utilizing cyclic constraints to only lookup up
the next 3 (default) levels. This should
heavily improve performance and reduce the amount of generated types.

Fixes

Breaking Changes

In general the depth limit of Path is no longer the max depth, but instead a 'lookahead' depth. E.g. if you have a depth limit of 3,
and are currently (while typing) at a depth of 2, the paths for the next 3 levels will be shown in autocompletion. You can no longer
constrain the max depth of the path, but only the lookahead depth. If this is a problem for you, please open an issue.

Value of Array Member, Optional Properties and Union Types

In 1.0.0 you received the full type for nested unions.

type A = { a: number | { nested: string } }

type NestedType = PathValue<A, 'a.nested'> // string

This is incorrect behavior, because a could also be a number and not an object with a nested property. This is now fixed.

PathValue was split into two different types:

  • GetPathValue for reading values
  • SetPathValue for setting values

the resulting types differ when accessing values in an object or setting them.

type A = {
  a: number | { nested: string }
  b: Record<string, number>
  c: string[]
  d?: { nested: string }
}

type NestedType1 = GetPathValue<A, 'a.nested'> // string | undefined
type NestedType2 = GetPathValue<A, 'b.key'> // number | undefined
type NestedType3 = GetPathValue<A, 'c.5'> // string | undefined
type NestedType4 = GetPathValue<A, 'd.nested'> // string | undefined

type NestedType5 = SetPathValue<A, 'a.nested', string> // string
type NestedType6 = SetPathValue<A, 'b.key', number> // number
type NestedType7 = SetPathValue<A, 'c.5', string> // string
type NestedType8 = SetPathValue<A, 'd.nested', string> // string

These type are used by their respective functions getByPath and setByPath and should more accurately represent the types of accessed values but can potentially break old code.

Custom Implementation

Implementation of custom getByPath and setByPath functions need to be updated for the new types.
If you implemented them to change the depth limit you might not need them anymore, as the (max) depth is now 40 (limited by TypeScript's recursion limit).
You still want to keep them, if you want to change the shown paths in autocompletion or have other use cases.
You only need to change the typing.

Old:

function getByPathDepth5<T extends SearchableObject, P extends Path<T, 5> & string>(
  object: T,
  path: P,
): PathValue<T, P, 5> {
  return getByPath(object, path) as PathValue<T, P, 5>
}

function setByPathDepth5<
  T extends SearchableObject,
  P extends Path<T, 5> & string,
  V extends PathValue<T, P, 5>,
>(object: T, path: P, value: V): void {
  setByPath(object, path, value as PathValue<T, P>)
}

New:

function getByPathDepth5<T extends SearchableObject, P extends Path<T, P, { depth: 5 }> & string>(
  object: T,
  path: P,
): GetPathValue<T, P> {
  return getByPath(object, path) as GetPathValue<T, P>
}

function setByPathDepth5<
  T extends SearchableObject,
  P extends Path<T, P, { onlyWriteable: true; depth: 5 }> & string,
>(object: T, path: P, value: SetPathValue<T, P>): void {
  setByPath(object, path, value as SetPathValue<T, P>)
}

Full Changelog: 1.0.6...2.0.0

1.0.6

25 Mar 10:49
59b1b05
Compare
Choose a tag to compare

What's Changed

  • Fix breaking change in Searchable object type by @Tofandel in #27

Full Changelog: 1.0.5...1.0.6

1.0.5

21 Mar 00:27
923e5d6
Compare
Choose a tag to compare

What's Changed

  • Fix getByPath throws if accessing a null value by @Tofandel in #23
  • Fix setByPath does not throw when assigning to non objects in browsers by @Tofandel in #25

New Contributors

Full Changelog: 1.0.4...1.0.5

1.0.4

07 Nov 10:17
a7117b2
Compare
Choose a tag to compare

What's Changed

  • Fixed wrong type transformation via vite-dts-plugin (see #15)
  • Fixed wrong cjs export filename
  • Fixed order of types export to be the first export
  • Enabled rollup of Typescript declaration files

Full Changelog: v1.0.3...1.0.4

1.0.3

02 Nov 23:26
1270758
Compare
Choose a tag to compare

What's Changed

  • fix(ci): publish pipeline & bump version to 1.0.3 by @saibotk in #14

Full Changelog: v1.0.2...1.0.3

v1.0.2

02 Nov 23:17
8345b0e
Compare
Choose a tag to compare

1.0.1

26 Mar 20:28
0adec2a
Compare
Choose a tag to compare

What's Changed

  • Rerelease with content now 😅

Full Changelog: 1.0.0...1.0.1

1.0.0

26 Mar 20:18
9fc3a0b
Compare
Choose a tag to compare

Initial Release 🎉

Full Changelog: https://github.com/clickbar/dot-diver/commits/1.0.0