Releases: plainbrew/next-utils
Release list
@plainbrew/next-typed-href@0.6.0
Minor Changes
-
#82
30d6ba9Thanks @akameco! - feat: require explicit type arguments on.routes()defineTypedHref.routes()anddefineTypedHrefWithNuqs.routes()now require
explicit<Routes, RouteParamsMap>type arguments. Calling them without type
arguments fails with a TypeScript error at the call site — previously
Routeswould silently widen tostring, defeating the type-safety the
library promises.// ❌ Type error AT this line: // "Expected 1 arguments, but got 0." // Hover shows the missing parameter's name and message. defineTypedHref.routes(); // ✅ OK defineTypedHref.routes<Routes, RouteParamsMap>();
The mechanism is a conditional rest parameter: when
string extends Routes
(i.e. no type argument was supplied),routesrequires a single phantom
argument whose name and type spell out the fix. WhenRoutesis a proper
literal union, the rest tuple is empty and the call is nullary as before.This is a type-level change only — no runtime behavior changes. Existing
callers that already pass explicit type arguments are unaffected.
@plainbrew/next-typed-href@0.5.0
@plainbrew/next-typed-href@0.4.0
Minor Changes
-
#61
5882460Thanks @akameco! - refactor: replace triple-curry with builder pattern, add.withOptions()Breaking changes
Both
defineTypedHrefanddefineTypedHrefWithNuqsnow use a builder pattern
inspired by tRPC'sinitTRPC.context<T>().create().defineTypedHref// before defineTypedHref<Routes, RouteParamsMap>(); // after defineTypedHref.routes<Routes, RouteParamsMap>();
defineTypedHrefWithNuqs// before defineTypedHrefWithNuqs<Routes, RouteParamsMap>()(nuqsMap); defineTypedHrefWithNuqs<Routes, RouteParamsMap>()({ requiredSearchParams: true, })(nuqsMap); // after defineTypedHrefWithNuqs.routes<Routes, RouteParamsMap>().nuqs(nuqsMap); defineTypedHrefWithNuqs .routes<Routes, RouteParamsMap>() .withOptions({ requiredSearchParams: true }) .nuqs(nuqsMap);
New feature:
.withOptions()requiredSearchParams: trueを渡すと、nuqs パーサーが定義されているルートでsearchParamsが必須になる。.withDefault()なし → フィールドが required(nullは渡せる).withDefault()あり → フィールドが optional
const { $href } = defineTypedHrefWithNuqs .routes<Routes, RouteParamsMap>() .withOptions({ requiredSearchParams: true }) .nuqs({ "/search": { q: parseAsString, // required (no withDefault) page: parseAsInteger.withDefault(1), // optional (has withDefault) }, }); $href({ route: "/search", searchParams: { q: "hello" } }); // OK $href({ route: "/search" }); // Type error: searchParams is required $href({ route: "/search", searchParams: { page: 2 } }); // Type error: q is required
@plainbrew/next-typed-href@0.3.0
Minor Changes
-
#58
34f31dfThanks @amotarao! - feat(nuqs): addrequiredSearchParamsoption todefineTypedHrefWithNuqsBreaking change
defineTypedHrefWithNuqsis now a 3-level curried function. An options call has been inserted as the second level:// before defineTypedHrefWithNuqs<Routes, RouteParamsMap>()(nuqsMap); // after defineTypedHrefWithNuqs<Routes, RouteParamsMap>()()(nuqsMap);
New feature
Pass
{ requiredSearchParams: true }in the second call to enforce thatsearchParamsis provided for routes with nuqs parsers defined.Fields without
.withDefault()become required; fields with.withDefault()remain optional.const { $href } = defineTypedHrefWithNuqs<Routes, RouteParamsMap>()({ requiredSearchParams: true, })({ "/search": { q: parseAsString, // required page: parseAsInteger.withDefault(1), // optional }, }); $href({ route: "/search", searchParams: { q: "hello" } }); // OK $href({ route: "/search", searchParams: { q: "hello", page: 2 } }); // OK $href({ route: "/search" }); // Type error $href({ route: "/search", searchParams: { page: 2 } }); // Type error
@plainbrew/vercel-basic-auth@0.2.1
@plainbrew/next-typed-href@0.2.1
@plainbrew/next-typed-href@0.2.0
Minor Changes
-
#28
4b54edbThanks @amotarao! - feat: Add defineTypedHrefWithNuqs for type-safe searchParams with nuqs parsers -
#46
eaeb183Thanks @amotarao! - fix: Support withDefault parsers in defineTypedHrefWithNuqs; null is now a type error for non-nullable params, and values equal to the default are omitted from the URL