import { QueryParamConfig } from './types' ; param param param defaultValue param includeNull export function withDefault < D , DefaultType extends D2 , D2 = D > ( param , defaultValue , includeNull ? ) ; export function withDefault < D , DefaultType extends D2 , D2 = D > ( param , defaultValue , includeNull ? ) ; export function withDefault < D , DefaultType extends D2 , D2 = D > ( param , defaultValue , includeNull = true ) { const decodeWithDefault = ( ... args ) : Exclude < D2 , null | undefined > | Exclude < D2 , undefined > | DefaultType => { const decodedValue = param . decode ( ... args ) ; if ( decodedValue === undefined ) { return defaultValue ; } if ( includeNull ) { if ( decodedValue === null ) { return defaultValue ; } else { return decodedValue as Exclude < D2 , undefined > ; } } return decodedValue as Exclude < D2 , undefined | null > ; } ; return { ... param , decode : decodeWithDefault } ; } export default withDefault ;