Skip to content

Commit da22f83

Browse files
committed
Enforce typing weakmap
1 parent ed4b3f3 commit da22f83

File tree

1 file changed

+3
-2
lines changed
  • packages/gitbook/src/lib/openapi

1 file changed

+3
-2
lines changed

packages/gitbook/src/lib/openapi/fetch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ export function resolveOpenAPIBlock<T extends OpenAPIBlockType = 'operation'>(
6363
args: ResolveOpenAPIBlockArgs<T>
6464
): Promise<OpenAPIBlockResult<T>> {
6565
if (weakmap.has(args.block)) {
66-
return weakmap.get(args.block);
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);
6768
}
6869

6970
const result = baseResolveOpenAPIBlock(args);
70-
weakmap.set(args.block, result as Promise<OpenAPIBlockResult>);
71+
weakmap.set(args.block, result);
7172
return result;
7273
}
7374

0 commit comments

Comments
 (0)