Skip to content

Releases: fenok/react-router-typesafe-routes

v1.2.2

21 Apr 19:36
Compare
Choose a tag to compare

Fixed

  • For routes without pathname/search/state params, non-empty objects are no longer accepted as these params.

v1.2.1

20 Jun 15:56
Compare
Choose a tag to compare

Fixed

  • Fix path generation when the first segment is optional. Previously, route(":optional?/:required").buildPath({ required: "req" }) would be "//req".

v1.2.0

22 Apr 11:17
Compare
Choose a tag to compare

Added

  • Add CommonJS support for environments that support the exports field in package.json.

v1.1.0

07 Apr 21:37
Compare
Choose a tag to compare

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 around type();
    • string(), number(), boolean(), and date() for creating types based on the corresponding primitives;
    • union() for creating unions of string, number, and boolean 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(), and assertIsValidDate() because they are embedded in new helpers, which allow to run additional checks after these assertions.

v1.0.0

23 Jan 21:17
Compare
Choose a tag to compare

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 with TOriginal in their type. This is technically a breaking change, but it only affects custom types where TRetrieved is not assignable to TOriginal, 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 to PathParam 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 like buildUrl/buildRelativeUrl.
  • setTypedSearchParams is switched to React Router implementation of functional updates.

Deprecated

  • buildUrl/buildRelativeUrl now behave exactly like buildPath/buildRelativePath and are therefore deprecated.

Removed

  • Remove all internal fields prefixed with __ from route objects.

v0.5.1

14 Dec 19:02
Compare
Choose a tag to compare

Added

Fixed

  • Sync node version requirements with react-router.

v0.5.0

15 Sep 00:47
Compare
Choose a tag to compare

Added

  • Expose route types (previously existed as internal __options__).

Changed

  • Renamed CreateRouteOptions and RouteOptions into RouteOptions and RouteTypes respectively.

v0.4.3

11 Sep 10:56
Compare
Choose a tag to compare

Added

  • Add throwable fallback.

v0.4.2

10 Sep 20:57
Compare
Choose a tag to compare

Added

  • Add CHANGELOG.md.
  • Add preserveUntyped option to setTypedSearchParams from useTypedSearchParams hook.
  • Add getUntypedSearchParams and getUntypedState methods to route object.

Fixed

  • Return value of buildState method is now properly typed as Record<string, unknown> instead of unknown.
  • Hook dependencies are now properly listed, which is checked by ESLint. This fixes useTypedSearchParams for dynamic routes.
  • Prevent access to internal useUpdatingRef helper.