From e0d3232a294b8eaa4886491fa3f1d59ce4ff792e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Dewitte?= Date: Wed, 3 Apr 2024 10:43:25 +0200 Subject: [PATCH 1/2] Fix SerializerCompiler type --- types/index.d.ts | 5 +---- types/index.test-d.ts | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 26bbf1f..5bd5d29 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -8,10 +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 diff --git a/types/index.test-d.ts b/types/index.test-d.ts index d1dbd85..7e27b0f 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -38,7 +38,7 @@ import SerializerSelector, { expectType(factory); const compiler = factory(externalSchemas1, {}) expectType(compiler); - const serializeFunc = compiler({ schema: sampleSchema }) + const serializeFunc = compiler({ schema: sampleSchema, method: '', url:'', httpStatus: '' }) expectType(serializeFunc); expectType(serializeFunc({ name: 'hello' })) @@ -88,6 +88,9 @@ expectType(writer); } const endpointSchema = { + method: '', + url: '', + httpStatus: '', schema: { $id: 'urn:schema:endpoint', $ref: 'urn:schema:ref' From ec131809adc475b2db3abf8a76078913220274a5 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sun, 8 Dec 2024 16:34:23 +0100 Subject: [PATCH 2/2] fix linting --- types/index.d.ts | 2 +- types/index.test-d.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index cbf0986..0546135 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -8,7 +8,7 @@ declare namespace SerializerSelector { options?: Options ) => SerializerCompiler - export type SerializerCompiler = (routeDef: RouteDefinition) => Serializer; + export type SerializerCompiler = (routeDef: RouteDefinition) => Serializer export type Serializer = (doc: any) => string export type RouteDefinition = { diff --git a/types/index.test-d.ts b/types/index.test-d.ts index b48620e..018759a 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -34,11 +34,11 @@ import SerializerSelector, { const externalSchemas1 = {} const factory = SerializerSelector() - expectType(factory); + expectType(factory) const compiler = factory(externalSchemas1, {}) - expectType(compiler); - const serializeFunc = compiler({ schema: sampleSchema, method: '', url:'', httpStatus: '' }) - expectType(serializeFunc); + expectType(compiler) + const serializeFunc = compiler({ schema: sampleSchema, method: '', url: '', httpStatus: '' }) + expectType(serializeFunc) expectType(serializeFunc({ name: 'hello' })) }