Releases: fenok/react-router-typesafe-routes
Releases · fenok/react-router-typesafe-routes
v1.2.2
v1.2.1
v1.2.0
v1.1.0
Added
- Introduce type objects that allow to fine-tune parsing and serialization logic for every route part.
- Add helpers for creating these type objects. They can generally be used instead of the old ones (see Migrating to Universal Types). The helpers are:
type()
for creating any type;parser()
for accessing the built-in parser, most likely for building custom wrappers aroundtype()
;string()
,number()
,boolean()
, anddate()
for creating types based on the corresponding primitives;union()
for creating unions ofstring
,number
, andboolean
values;zod()
for creating types based on Zod Types;yup()
for creating types based on Yup Schemas.
- Route params input and output types are now much more readable in IDE hints.
- Specifying a path pattern with leading or trailing slashes or a child route starting with a lowercase letter will now lead to a human-readable error.
Fixed
- For types of parsed path params, search params, and state fields, keys that correspond to type objects that return
undefined
upon a parsing error are no longer optional.
Deprecated
- Deprecate old helpers for creating type objects:
createType()
,stringType()
,numberType()
,booleanType()
,dateType()
,oneOfType()
,arrayOfType()
,throwable
, and all types that are exclusive to them. - Deprecate
assertIsString()
,assertIsNumber()
,assertIsBoolean()
,assertIsArray()
, andassertIsValidDate()
because they are embedded in new helpers, which allow to run additional checks after these assertions.
v1.0.0
Added
- Add support for optional path segments.
- Add
types()
helper for route types composition. - Add
getUntypedParams()
method to route object.
Fixed
- Intermediate splat (star) segments in absolute path patterns are now properly detected. Previously, their detection didn't work properly if dynamic segments were present. It means that such star params will now correctly appear in parsed (typed) path params.
- Multiple intermediate stars are now properly removed from relative path pattern. This also fixes building URL paths from such patterns.
- Upon building URL paths from patterns with only intermediate stars, the
*
parameter is not present anymore, because it doesn't actually do anything (intermediate stars are simply removed).
Changed
- Breaking: Fallbacks are now run through type functions to ensure fallbacks validity, and therefore
TRetrieved
was replaced withTOriginal
in their type. This is technically a breaking change, but it only affects custom types whereTRetrieved
is not assignable toTOriginal
, which should be extremely rare. - Breaking: Minimal required React Router version is changed to
6.7.0
due to optional path segments support. - Breaking: Rename
ExtractRouteParams
toPathParam
for parity with React Router. - Breaking: In route object,
$
no longer contains undecorated child routes. Instead, it now contains routes that lack parent path pattern and path type objects, but inherit everything else. buildPath
/buildRelativePath
now accept additional arguments and behave exactly likebuildUrl
/buildRelativeUrl
.setTypedSearchParams
is switched to React Router implementation of functional updates.
Deprecated
buildUrl
/buildRelativeUrl
now behave exactly likebuildPath
/buildRelativePath
and are therefore deprecated.
Removed
- Remove all internal fields prefixed with
__
from route objects.
v0.5.1
v0.5.0
v0.4.3
v0.4.2
Added
- Add CHANGELOG.md.
- Add
preserveUntyped
option tosetTypedSearchParams
fromuseTypedSearchParams
hook. - Add
getUntypedSearchParams
andgetUntypedState
methods to route object.
Fixed
- Return value of
buildState
method is now properly typed asRecord<string, unknown>
instead ofunknown
. - Hook dependencies are now properly listed, which is checked by ESLint. This fixes
useTypedSearchParams
for dynamic routes. - Prevent access to internal
useUpdatingRef
helper.