generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Export the SearchParams type in both client & server bundles (#710
- Loading branch information
Showing
7 changed files
with
87 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { createSearchParamsCache, type SearchParams } from './cache' | ||
export { createSearchParamsCache } from './cache' | ||
export type { HistoryOptions, Options, SearchParams } from './defs' | ||
export * from './parsers' | ||
export { createSerializer } from './serializer' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { expectError, expectType } from 'tsd' | ||
import { createSerializer, parseAsInteger, parseAsString } from '../../dist' | ||
|
||
// prettier-ignore | ||
{ | ||
const serialize = createSerializer({ | ||
foo: parseAsString, | ||
bar: parseAsInteger | ||
}) | ||
// It returns a string | ||
expectType<string>(serialize({})) | ||
expectType<string>(serialize({ foo: 'foo', bar: 42 })) | ||
expectType<string>(serialize({ foo: null, bar: null })) | ||
// With base | ||
expectType<string>(serialize('/', {})) | ||
expectType<string>(serialize('/', { foo: 'foo', bar: 42 })) | ||
expectType<string>(serialize('/', { foo: null, bar: null })) | ||
expectType<string>(serialize(new URLSearchParams(), {})) | ||
expectType<string>(serialize(new URLSearchParams(), { foo: 'foo', bar: 42 })) | ||
expectType<string>(serialize(new URLSearchParams(), { foo: null, bar: null })) | ||
expectType<string>(serialize(new URL('https://example.com'), {})) | ||
expectType<string>(serialize(new URL('https://example.com'), { foo: 'foo', bar: 42 })) | ||
expectType<string>(serialize(new URL('https://example.com'), { foo: null, bar: null })) | ||
// Clearing from base | ||
expectType<string>(serialize('/', null)) | ||
expectType<string>(serialize(new URLSearchParams(), null)) | ||
expectType<string>(serialize(new URL('https://example.com'), null)) | ||
} | ||
|
||
// It accepts partial inputs | ||
{ | ||
const serialize = createSerializer({ | ||
foo: parseAsString, | ||
bar: parseAsInteger | ||
}) | ||
|
||
expectType<string>(serialize({ foo: 'foo' })) | ||
expectType<string>(serialize({ bar: 42 })) | ||
} | ||
|
||
// It doesn't accept extra properties | ||
{ | ||
const serialize = createSerializer({ | ||
foo: parseAsString, | ||
bar: parseAsInteger | ||
}) | ||
expectError(() => { | ||
serialize({ nope: null }) | ||
}) | ||
} |