|
1 | 1 | import { GetServerSideProps } from 'next' |
| 2 | +import type { ServerResponse } from 'http' |
2 | 3 | import { Operation } from '@/rest/components/types' |
| 4 | +import type { ExtendedRequest, AllVersions } from '@/types/types' |
3 | 5 | import { RestReferencePage } from '@/rest/components/RestReferencePage' |
4 | 6 | import { getMainContext, MainContext, MainContextT } from '@/frame/components/context/MainContext' |
5 | 7 | import { |
@@ -60,16 +62,18 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) => |
60 | 62 | await import('@/versions/lib/non-enterprise-default-version') |
61 | 63 | const nonEnterpriseDefaultVersion = nonEnterpriseDefaultVersionModule.default as string |
62 | 64 |
|
63 | | - const req = context.req as any |
64 | | - const res = context.res as any |
65 | | - const tocLandingContext = getTocLandingContextFromRequest(req) |
| 65 | + const req = context.req as unknown as ExtendedRequest |
| 66 | + const res = context.res as unknown as ServerResponse |
| 67 | + const tocLandingContext = getTocLandingContextFromRequest( |
| 68 | + req as unknown as Parameters<typeof getTocLandingContextFromRequest>[0], |
| 69 | + ) |
66 | 70 | // e.g. the `activity` from `/en/rest/activity/events` |
67 | 71 | const category = context.params!.category as string |
68 | 72 | let subcategory = context.params!.subcategory as string |
69 | 73 | const currentVersion = context.params!.versionId as string |
70 | | - const currentLanguage = req.context.currentLanguage as string |
71 | | - const allVersions = req.context.allVersions |
72 | | - const queryApiVersion = context.query.apiVersion |
| 74 | + const currentLanguage = req.context!.currentLanguage as string |
| 75 | + const allVersions = req.context!.allVersions as AllVersions |
| 76 | + const queryApiVersion = context.query.apiVersion as string |
73 | 77 | const apiVersion = allVersions[currentVersion].apiVersions.includes(queryApiVersion) |
74 | 78 | ? queryApiVersion |
75 | 79 | : allVersions[currentVersion].latestApiVersion |
@@ -135,7 +139,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) => |
135 | 139 | subCatOperations, |
136 | 140 | currentLanguage, |
137 | 141 | currentVersion, |
138 | | - req.context, |
| 142 | + req.context!, |
139 | 143 | )) as MinitocItemsT |
140 | 144 |
|
141 | 145 | for (const operationMinitoc of miniTocItems.restOperationsMiniTocItems) { |
@@ -191,7 +195,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) => |
191 | 195 | restOperations, |
192 | 196 | currentLanguage, |
193 | 197 | currentVersion, |
194 | | - req.context, |
| 198 | + req.context!, |
195 | 199 | )) as MinitocItemsT |
196 | 200 |
|
197 | 201 | if (restOperationsMiniTocItems) { |
|
0 commit comments