Skip to content

Commit d828073

Browse files
committed
fix(core): Make (de-)serializer only optional in builder functions
1 parent 5a83450 commit d828073

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

projects/ngqp/core/src/lib/model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export type ParamDeserializer<T> = (value: string | null) => T | null;
1111
*/
1212
export interface QueryParamControlOpts<T> {
1313
name: string;
14-
serialize?: ParamSerializer<T>;
15-
deserialize?: ParamDeserializer<T>;
16-
debounceTime?: number;
14+
serialize: ParamSerializer<T>;
15+
deserialize: ParamDeserializer<T>;
16+
debounceTime?: number | null;
1717
}
1818

1919
/**

projects/ngqp/core/src/lib/query-param-builder.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
DEFAULT_STRING_SERIALIZER
1010
} from './serializers';
1111

12+
type OverwritePartial<T1, T2 extends keyof T1> = Pick<T1, Exclude<keyof T1, T2>> & Partial<Pick<T1, T2>>;
13+
export type QueryParamControlOptsInput<T> = OverwritePartial<QueryParamControlOpts<T>, 'serialize' | 'deserialize'>;
14+
1215
/**
1316
* TODO Documentation
1417
*/
@@ -32,7 +35,7 @@ export class QueryParamBuilder {
3235
/**
3336
* TODO Documentation
3437
*/
35-
public param(config: QueryParamControlOpts<string>): QueryParamControl<string> {
38+
public param(config: QueryParamControlOptsInput<string>): QueryParamControl<string> {
3639
return new QueryParamControl({
3740
serialize: DEFAULT_STRING_SERIALIZER,
3841
deserialize: DEFAULT_STRING_DESERIALIZER,
@@ -43,7 +46,7 @@ export class QueryParamBuilder {
4346
/**
4447
* TODO Documentation
4548
*/
46-
public numericParam(config: QueryParamControlOpts<number>): QueryParamControl<number> {
49+
public numericParam(config: QueryParamControlOptsInput<number>): QueryParamControl<number> {
4750
return new QueryParamControl({
4851
serialize: DEFAULT_NUMBER_SERIALIZER,
4952
deserialize: DEFAULT_NUMBER_DESERIALIZER,
@@ -54,7 +57,7 @@ export class QueryParamBuilder {
5457
/**
5558
* TODO Documentation
5659
*/
57-
public booleanParam(config: QueryParamControlOpts<boolean>): QueryParamControl<boolean> {
60+
public booleanParam(config: QueryParamControlOptsInput<boolean>): QueryParamControl<boolean> {
5861
return new QueryParamControl({
5962
serialize: DEFAULT_BOOLEAN_SERIALIZER,
6063
deserialize: DEFAULT_BOOLEAN_DESERIALIZER,

0 commit comments

Comments
 (0)