Skip to content

Commit 4d52b64

Browse files
committed
ref: move serializer code to serializer file, duh
1 parent 2faff69 commit 4d52b64

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/nuqs/src/parsers.ts

-9
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,3 @@ export type inferParserType<Input> =
464464
: Input extends Record<string, ParserBuilder<any>>
465465
? inferParserRecordType<Input>
466466
: never
467-
468-
type inferSingleSerializerType<Parser> =
469-
Parser extends ParserBuilder<infer Value> ? Value | null : never
470-
471-
export type inferSerializerRecordType<
472-
Map extends Record<string, ParserBuilder<any>>
473-
> = {
474-
[Key in keyof Map]: inferSingleSerializerType<Map[Key]>
475-
}

packages/nuqs/src/serializer.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import type { Options } from './defs'
2-
import type { inferSerializerRecordType, ParserBuilder } from './parsers'
2+
import type { ParserBuilder } from './parsers'
33
import { renderQueryString } from './url-encoding'
44

55
type Base = string | URLSearchParams | URL
66
type ParserWithOptionalDefault<T> = ParserBuilder<T> & { defaultValue?: T }
77

8+
type inferSingleSerializerType<Parser> =
9+
Parser extends ParserBuilder<infer Value> ? Value | null : never
10+
11+
export type inferSerializerRecordType<
12+
Map extends Record<string, ParserBuilder<any>>
13+
> = {
14+
[Key in keyof Map]: inferSingleSerializerType<Map[Key]>
15+
}
16+
817
export function createSerializer<
918
Parsers extends Record<string, ParserWithOptionalDefault<any>>
1019
>(

0 commit comments

Comments
 (0)