@@ -64,11 +64,11 @@ export function resolveOpenAPIBlock<T extends OpenAPIBlockType = 'operation'>(
64
64
) : Promise < OpenAPIBlockResult < T > > {
65
65
if ( weakmap . has ( args . block ) ) {
66
66
// We enforce the type here cause weakmap doesn't know the type of the value
67
- return weakmap . get < AnyOpenAPIOperationBlock , Promise < OpenAPIBlockResult < T > > > ( args . block ) ;
67
+ return weakmap . get ( args . block ) as Promise < OpenAPIBlockResult < T > > ;
68
68
}
69
69
70
70
const result = baseResolveOpenAPIBlock ( args ) ;
71
- weakmap . set ( args . block , result ) ;
71
+ weakmap . set ( args . block , result as Promise < OpenAPIBlockResult > ) ;
72
72
return result ;
73
73
}
74
74
@@ -80,14 +80,14 @@ async function baseResolveOpenAPIBlock<T extends OpenAPIBlockType = 'operation'>
80
80
) : Promise < OpenAPIBlockResult < T > > {
81
81
const { context, block, type = 'operation' } = args ;
82
82
if ( ! block . data . path || ! block . data . method ) {
83
- return createResults ( null ) ;
83
+ return createResults < T > ( null ) ;
84
84
}
85
85
86
86
const ref = block . data . ref ;
87
87
const resolved = ref ? await resolveContentRef ( ref , context ) : null ;
88
88
89
89
if ( ! resolved ) {
90
- return createResults ( null ) ;
90
+ return createResults < T > ( null ) ;
91
91
}
92
92
93
93
try {
@@ -109,7 +109,7 @@ async function baseResolveOpenAPIBlock<T extends OpenAPIBlockType = 'operation'>
109
109
} ) ;
110
110
}
111
111
112
- return createResults ( data , resolved . href ) ;
112
+ return createResults < T > ( data , resolved . href ) ;
113
113
} catch ( error ) {
114
114
if ( error instanceof OpenAPIParseError ) {
115
115
return { error } ;
@@ -185,13 +185,13 @@ async function fetchFilesystemUncached(
185
185
/**
186
186
* Create a result for OpenAPI based on the type.
187
187
*/
188
- function createResults < T extends OpenAPIOperationData | OpenAPIModelsData > (
189
- data : T | null ,
188
+ function createResults < T extends OpenAPIBlockType > (
189
+ data : OpenAPIOperationData | OpenAPIModelsData | null ,
190
190
specUrl ?: string
191
191
) : OpenAPIBlockResult < T > {
192
192
return {
193
193
error : undefined ,
194
194
data,
195
195
specUrl,
196
- } ;
196
+ } as OpenAPIBlockResult < T > ;
197
197
}
0 commit comments