Remove no-explicit-any violations from REST pages and components (#61… · github/docs@c9b9392 · GitHub
Skip to content

Commit c9b9392

Browse files
heiskrCopilot
andauthored
Remove no-explicit-any violations from REST pages and components (#61664)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cf2408b commit c9b9392

5 files changed

Lines changed: 24 additions & 22 deletions

File tree

‎eslint.config.ts‎

Lines changed: 0 additions & 4 deletions

‎src/rest/components/get-rest-code-samples.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function escapeShellValue(value: string): string {
2626
return value.replace(/'/g, "'\\''")
2727
}
2828

29-
type CodeExamples = Record<string, any>
29+
type CodeExamples = Record<string, unknown>
3030

3131
// If the content type is application/x-www-form-urlencoded the format of
3232
// the shell example is --data-urlencode param1=value1 --data-urlencode param2=value2
@@ -216,7 +216,7 @@ export function getGHExample(
216216
if (hasArrays || isGistEndpoint) {
217217
const jsonBody = JSON.stringify(
218218
bodyParameters,
219-
(key: string, value: any) => {
219+
(key: string, value: unknown) => {
220220
// Convert numeric strings back to numbers for API compatibility
221221
if (typeof value === 'string' && /^\d+$/.test(value)) {
222222
return parseInt(value, 10)

‎src/rest/pages/category.tsx‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { GetServerSideProps } from 'next'
2+
import type { ServerResponse } from 'http'
23
import { Operation } from '@/rest/components/types'
4+
import type { ExtendedRequest, AllVersions } from '@/types/types'
35
import { RestReferencePage } from '@/rest/components/RestReferencePage'
46
import { getMainContext, MainContext, MainContextT } from '@/frame/components/context/MainContext'
57
import {
@@ -60,16 +62,18 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
6062
await import('@/versions/lib/non-enterprise-default-version')
6163
const nonEnterpriseDefaultVersion = nonEnterpriseDefaultVersionModule.default as string
6264

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+
)
6670
// e.g. the `activity` from `/en/rest/activity/events`
6771
const category = context.params!.category as string
6872
let subcategory = context.params!.subcategory as string
6973
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
7377
const apiVersion = allVersions[currentVersion].apiVersions.includes(queryApiVersion)
7478
? queryApiVersion
7579
: allVersions[currentVersion].latestApiVersion
@@ -135,7 +139,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
135139
subCatOperations,
136140
currentLanguage,
137141
currentVersion,
138-
req.context,
142+
req.context!,
139143
)) as MinitocItemsT
140144

141145
for (const operationMinitoc of miniTocItems.restOperationsMiniTocItems) {
@@ -191,7 +195,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
191195
restOperations,
192196
currentLanguage,
193197
currentVersion,
194-
req.context,
198+
req.context!,
195199
)) as MinitocItemsT
196200

197201
if (restOperationsMiniTocItems) {

‎src/rest/pages/subcategory.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { GetServerSideProps } from 'next'
2+
import type { ServerResponse } from 'http'
23
import { Operation } from '@/rest/components/types'
4+
import type { ExtendedRequest, AllVersions } from '@/types/types'
35
import { RestReferencePage } from '@/rest/components/RestReferencePage'
46
import {
57
addUINamespaces,
@@ -37,15 +39,15 @@ export default function SubCategory({ mainContext, automatedPageContext, restOpe
3739
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
3840
const { default: getRest, getRestMiniTocItems } = await import('@/rest/lib/index')
3941

40-
const req = context.req as any
41-
const res = context.res as any
42+
const req = context.req as unknown as ExtendedRequest
43+
const res = context.res as unknown as ServerResponse
4244
// e.g. the `activity` from `/en/rest/activity/events`
4345
const category = context.params!.category as string
4446
let subCategory = context.params!.subcategory as string
4547
const currentVersion = context.params!.versionId as string
46-
const currentLanguage = req.context.currentLanguage as string
47-
const allVersions = req.context.allVersions
48-
const queryApiVersion = context.query.apiVersion
48+
const currentLanguage = req.context!.currentLanguage as string
49+
const allVersions = req.context!.allVersions as AllVersions
50+
const queryApiVersion = context.query.apiVersion as string
4951
const apiVersion = allVersions[currentVersion].apiVersions.includes(queryApiVersion)
5052
? queryApiVersion
5153
: allVersions[currentVersion].latestApiVersion
@@ -77,7 +79,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
7779
restOperations,
7880
currentLanguage,
7981
currentVersion,
80-
req.context,
82+
req.context!,
8183
)) as MinitocItemsT
8284

8385
if (restOperationsMiniTocItems) {

‎src/rest/scripts/utils/update-markdown.ts‎

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)