Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SerializerCompiler type #48

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ declare namespace SerializerSelector {
options?: Options
) => SerializerCompiler

export type SerializerCompiler = (
externalSchemas?: unknown,
options?: Options
) => Serializer

export type SerializerCompiler = (routeDef: RouteDefinition) => Serializer
export type Serializer = (doc: any) => string

export type RouteDefinition = {
Expand Down
5 changes: 4 additions & 1 deletion types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import SerializerSelector, {
expectType<SerializerFactory>(factory)
const compiler = factory(externalSchemas1, {})
expectType<SerializerCompiler>(compiler)
const serializeFunc = compiler({ schema: sampleSchema })
const serializeFunc = compiler({ schema: sampleSchema, method: '', url: '', httpStatus: '' })
expectType<Serializer>(serializeFunc)

expectType<string>(serializeFunc({ name: 'hello' }))
Expand Down Expand Up @@ -86,6 +86,9 @@ expectType<SerializerFactory>(writer)
}

const endpointSchema = {
method: '',
url: '',
httpStatus: '',
schema: {
$id: 'urn:schema:endpoint',
$ref: 'urn:schema:ref'
Expand Down
Loading