From 617b90c86fcf81168ee3346b5c6f982d5d977153 Mon Sep 17 00:00:00 2001 From: curfew-marathon Date: Thu, 2 Jul 2026 21:43:34 -0400 Subject: [PATCH] chore: upgrade to TypeScript 6.0.3 and clean up legacy patterns --- package-lock.json | 8 +++---- package.json | 6 ++--- .../AuthorizationModel/SyntaxTransformer.ts | 9 +++++--- .../Docs/RelationshipTuples/Viewer.tsx | 4 +--- .../SnippetViewer/BatchCheckRequestViewer.tsx | 3 +-- .../Docs/SnippetViewer/CheckRequestViewer.tsx | 3 +-- .../SnippetViewer/ExecuteApiRequestViewer.tsx | 23 ++++++++----------- .../ListObjectsRequestViewer.tsx | 3 +-- .../SnippetViewer/ListUsersRequestViewer.tsx | 3 +-- .../icons/animations/AnimatedIcon.tsx | 14 +++++++---- .../icons/animations/auth0.lottie.ts | 5 ++-- .../icons/animations/code.lottie.ts | 5 ++-- .../icons/animations/community.lottie.ts | 5 ++-- .../icons/animations/fast.lottie.ts | 5 ++-- .../icons/animations/model.lottie.ts | 5 ++-- .../icons/animations/open.lottie.ts | 5 ++-- src/components/icons/animations/types.ts | 1 + src/pages/api/service.tsx | 14 +++++++---- src/theme/NavbarItem/NavbarNavLink.tsx | 17 +++++++++++--- tsconfig.json | 6 ++--- 20 files changed, 81 insertions(+), 63 deletions(-) create mode 100644 src/components/icons/animations/types.ts diff --git a/package-lock.json b/package-lock.json index d1a79cea56..bd687d01c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "husky": "9.1.7", "markdown-link-check": "^3.14.2", "prettier": "3.9.1", - "typescript": "5.9.3" + "typescript": "6.0.3" } }, "node_modules/@algolia/abtesting": { @@ -22145,9 +22145,9 @@ } }, "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", + "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", "devOptional": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index bd2e6a72c1..996373a7b1 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "write-heading-ids": "docusaurus write-heading-ids", "docker:build": "docker build . -t openfga-docs-ui", "docker:run": "docker run -p ${PORT:-3000}:3000 openfga-docs-ui", - "typecheck": "tsc --skipLibCheck", - "lint": "eslint . --ext .ts --ext .tsx", + "typecheck": "tsc", + "lint": "eslint .", "lint:fix": "npm run lint -- --fix", "format:check": "prettier --check src/**", "format:fix": "prettier --write src/**" @@ -61,7 +61,7 @@ "husky": "9.1.7", "markdown-link-check": "^3.14.2", "prettier": "3.9.1", - "typescript": "5.9.3" + "typescript": "6.0.3" }, "overrides": { "semver": "^7.7.1" diff --git a/src/components/Docs/AuthorizationModel/SyntaxTransformer.ts b/src/components/Docs/AuthorizationModel/SyntaxTransformer.ts index df69f8a47f..1b7db8b68f 100644 --- a/src/components/Docs/AuthorizationModel/SyntaxTransformer.ts +++ b/src/components/Docs/AuthorizationModel/SyntaxTransformer.ts @@ -9,18 +9,21 @@ export enum SyntaxFormat { Dsl = 'dsl', } +const isTypeDefinition = (config: AuthorizationModel | TypeDefinition): config is TypeDefinition => + !(config as AuthorizationModel).type_definitions && Boolean((config as TypeDefinition).type); + export const loadSyntax = ( configuration: AuthorizationModel, format: SyntaxFormat = SyntaxFormat.Json, skipVersion?: boolean, ) => { - let config = configuration; + let config: AuthorizationModel = configuration; switch (format) { case SyntaxFormat.Dsl: - if (!config.type_definitions && (config as unknown as TypeDefinition).type) { + if (isTypeDefinition(config)) { config = { schema_version: SchemaVersion.OneDotOne, - type_definitions: [config as unknown as TypeDefinition], + type_definitions: [config], id: '', }; skipVersion = true; diff --git a/src/components/Docs/RelationshipTuples/Viewer.tsx b/src/components/Docs/RelationshipTuples/Viewer.tsx index 300e7d64f4..7e25ea5b65 100644 --- a/src/components/Docs/RelationshipTuples/Viewer.tsx +++ b/src/components/Docs/RelationshipTuples/Viewer.tsx @@ -11,9 +11,7 @@ interface RelationshipTuple { export interface RelationshipCondition { name: string; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - context?: Record; + context?: Record; } interface RelationshipTuplesViewerOpts { diff --git a/src/components/Docs/SnippetViewer/BatchCheckRequestViewer.tsx b/src/components/Docs/SnippetViewer/BatchCheckRequestViewer.tsx index ee72e177c3..b6a90e1ec9 100644 --- a/src/components/Docs/SnippetViewer/BatchCheckRequestViewer.tsx +++ b/src/components/Docs/SnippetViewer/BatchCheckRequestViewer.tsx @@ -10,8 +10,7 @@ interface Check { correlation_id: string; allowed: boolean; contextualTuples?: TupleKey[]; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - context?: Record; + context?: Record; } interface BatchCheckRequestViewerOpts extends DefaultTabbedViewerOpts { authorizationModelId?: string; diff --git a/src/components/Docs/SnippetViewer/CheckRequestViewer.tsx b/src/components/Docs/SnippetViewer/CheckRequestViewer.tsx index 070a3545ec..60ff9384d4 100644 --- a/src/components/Docs/SnippetViewer/CheckRequestViewer.tsx +++ b/src/components/Docs/SnippetViewer/CheckRequestViewer.tsx @@ -11,8 +11,7 @@ interface CheckRequestViewerOpts { allowed: boolean; contextualTuples?: TupleKey[]; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - context?: Record; + context?: Record; skipSetup?: boolean; pseudoCodeMode?: boolean; allowedLanguages?: SupportedLanguage[]; diff --git a/src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx b/src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx index fd435d3e15..ad5f4fe9f5 100644 --- a/src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx +++ b/src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx @@ -6,8 +6,9 @@ import assertNever from 'assert-never/index'; // Helpers – value serialisation per language // --------------------------------------------------------------------------- -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function jsValue(val: any, indent: number): string { +type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }; + +function jsValue(val: JsonValue, indent: number): string { if (typeof val === 'string') return `"${val}"`; if (typeof val === 'number' || typeof val === 'boolean') return String(val); if (Array.isArray(val)) { @@ -23,8 +24,7 @@ function jsValue(val: any, indent: number): string { return String(val); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function pyValue(val: any, indent: number): string { +function pyValue(val: JsonValue, indent: number): string { if (typeof val === 'string') return `"${val}"`; if (typeof val === 'number') return String(val); if (typeof val === 'boolean') return val ? 'True' : 'False'; @@ -41,8 +41,7 @@ function pyValue(val: any, indent: number): string { return String(val); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function goValue(val: any, indent: number): string { +function goValue(val: JsonValue, indent: number): string { if (typeof val === 'string') return `"${val}"`; if (typeof val === 'number' || typeof val === 'boolean') return String(val); if (typeof val === 'object' && val !== null) { @@ -54,8 +53,7 @@ function goValue(val: any, indent: number): string { return String(val); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function javaValue(val: any, indent: number): string { +function javaValue(val: JsonValue, indent: number): string { if (typeof val === 'string') return `"${val}"`; if (typeof val === 'number' || typeof val === 'boolean') return String(val); if (typeof val === 'object' && val !== null) { @@ -67,8 +65,7 @@ function javaValue(val: any, indent: number): string { return String(val); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function csharpValue(val: any, indent: number): string { +function csharpValue(val: JsonValue, indent: number): string { if (typeof val === 'string') return `"${val}"`; if (typeof val === 'number' || typeof val === 'boolean') return String(val).toLowerCase(); if (typeof val === 'object' && val !== null) { @@ -118,8 +115,7 @@ function buildCurlSnippet(opts: { path: string; pathParams?: Record; queryParams?: Record; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - body?: Record; + body?: Record; streaming?: boolean; }): string { const { method, path, pathParams, queryParams, body, streaming } = opts; @@ -158,8 +154,7 @@ interface ExecuteApiRequestViewerOpts { /** Path parameter substitutions. */ pathParams?: Record; /** Request body (omit for GET). */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - body?: Record; + body?: Record; /** Query parameter key-value pairs. */ queryParams?: Record; /** Optional example response shown in a trailing comment. */ diff --git a/src/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsx b/src/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsx index 1e1eac4595..8ed77508d7 100644 --- a/src/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsx +++ b/src/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsx @@ -10,8 +10,7 @@ interface ListObjectsRequestViewerOpts { objectType: string; contextualTuples?: TupleKey[]; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - context?: Record; + context?: Record; expectedResults: string[]; skipSetup?: boolean; pseudoCodeMode?: boolean; diff --git a/src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx b/src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx index e5bbe59fae..a8bf00b2f4 100644 --- a/src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx +++ b/src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx @@ -12,8 +12,7 @@ interface ListUsersRequestViewerOpts { userFilterRelation?: string; contextualTuples?: TupleKey[]; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - context?: Record; + context?: Record; expectedResults: ListUsersResponse; skipSetup?: boolean; pseudoCodeMode?: boolean; diff --git a/src/components/icons/animations/AnimatedIcon.tsx b/src/components/icons/animations/AnimatedIcon.tsx index 455e986ac8..0dd86608ec 100644 --- a/src/components/icons/animations/AnimatedIcon.tsx +++ b/src/components/icons/animations/AnimatedIcon.tsx @@ -1,16 +1,20 @@ import * as React from 'react'; import BrowserOnly from '@docusaurus/BrowserOnly'; +const Player = React.lazy(() => + import('@lottiefiles/react-lottie-player').then((module) => ({ default: module.Player })), +); + type AnimatedIconProps = { element?: string | object }; const AnimatedIcon: React.FC = ({ element }) => { return (
- {() => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const { Player } = require('@lottiefiles/react-lottie-player'); - return ; - }} + {() => ( + + + + )}
); diff --git a/src/components/icons/animations/auth0.lottie.ts b/src/components/icons/animations/auth0.lottie.ts index b6b28e172b..ecf1bbbc8a 100644 --- a/src/components/icons/animations/auth0.lottie.ts +++ b/src/components/icons/animations/auth0.lottie.ts @@ -1,5 +1,6 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const auth0Lottie: any = { +import type { LottieAnimationData } from './types'; + +export const auth0Lottie: LottieAnimationData = { v: '5.7.4', fr: 60, ip: 0, diff --git a/src/components/icons/animations/code.lottie.ts b/src/components/icons/animations/code.lottie.ts index 7becff3ba9..f54a562fcb 100644 --- a/src/components/icons/animations/code.lottie.ts +++ b/src/components/icons/animations/code.lottie.ts @@ -1,5 +1,6 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const codeLottie: any = { +import type { LottieAnimationData } from './types'; + +export const codeLottie: LottieAnimationData = { v: '5.7.4', fr: 60, ip: 0, diff --git a/src/components/icons/animations/community.lottie.ts b/src/components/icons/animations/community.lottie.ts index 4c91ebee1d..c31985b0ac 100644 --- a/src/components/icons/animations/community.lottie.ts +++ b/src/components/icons/animations/community.lottie.ts @@ -1,5 +1,6 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const communityLottie: any = { +import type { LottieAnimationData } from './types'; + +export const communityLottie: LottieAnimationData = { v: '5.7.4', fr: 60, ip: 0, diff --git a/src/components/icons/animations/fast.lottie.ts b/src/components/icons/animations/fast.lottie.ts index 15ca2d768d..8c0b62dc88 100644 --- a/src/components/icons/animations/fast.lottie.ts +++ b/src/components/icons/animations/fast.lottie.ts @@ -1,5 +1,6 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const fastLottie: any = { +import type { LottieAnimationData } from './types'; + +export const fastLottie: LottieAnimationData = { v: '5.7.4', fr: 60, ip: 0, diff --git a/src/components/icons/animations/model.lottie.ts b/src/components/icons/animations/model.lottie.ts index 32daa56c3b..cdeff6f5ef 100644 --- a/src/components/icons/animations/model.lottie.ts +++ b/src/components/icons/animations/model.lottie.ts @@ -1,5 +1,6 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const modelLottie: any = { +import type { LottieAnimationData } from './types'; + +export const modelLottie: LottieAnimationData = { v: '5.7.4', fr: 60, ip: 0, diff --git a/src/components/icons/animations/open.lottie.ts b/src/components/icons/animations/open.lottie.ts index 62ba640310..2b095cb1d7 100644 --- a/src/components/icons/animations/open.lottie.ts +++ b/src/components/icons/animations/open.lottie.ts @@ -1,5 +1,6 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const openLottie: any = { +import type { LottieAnimationData } from './types'; + +export const openLottie: LottieAnimationData = { v: '5.7.4', fr: 60, ip: 0, diff --git a/src/components/icons/animations/types.ts b/src/components/icons/animations/types.ts new file mode 100644 index 0000000000..4267b40f2a --- /dev/null +++ b/src/components/icons/animations/types.ts @@ -0,0 +1 @@ +export type LottieAnimationData = Record; diff --git a/src/pages/api/service.tsx b/src/pages/api/service.tsx index a5d0f69329..b995a2a4e5 100644 --- a/src/pages/api/service.tsx +++ b/src/pages/api/service.tsx @@ -4,6 +4,10 @@ import BrowserOnly from '@docusaurus/BrowserOnly'; import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +const SwaggerUI = React.lazy(() => + import('../../components/SwaggerUI/swagger-ui').then((module) => ({ default: module.SwaggerUI })), +); + const ApiService = () => { const { siteConfig } = useDocusaurusContext(); const apiDocsBasePath = siteConfig.customFields?.apiDocsBasePath as string | undefined; @@ -16,11 +20,11 @@ const ApiService = () => { return ( Loading...}> - {() => { - // eslint-disable-next-line @typescript-eslint/no-require-imports - const { SwaggerUI } = require('../../components/SwaggerUI/swagger-ui'); - return ; - }} + {() => ( + Loading...}> + + + )} ); diff --git a/src/theme/NavbarItem/NavbarNavLink.tsx b/src/theme/NavbarItem/NavbarNavLink.tsx index 3304a35edc..cc69cbc395 100644 --- a/src/theme/NavbarItem/NavbarNavLink.tsx +++ b/src/theme/NavbarItem/NavbarNavLink.tsx @@ -13,6 +13,19 @@ interface GithubStarsSessionStorage { retrievedTime: number; } +function readCachedGithubStars(): GithubStarsSessionStorage | null { + try { + const raw = sessionStorage.getItem(GITHUB_STARS_SESSION_STORAGE_NAME); + if (!raw) { + return null; + } + const parsed = JSON.parse(raw); + return typeof parsed?.count === 'number' && typeof parsed?.retrievedTime === 'number' ? parsed : null; + } catch { + return null; + } +} + export default function NavbarNavLink({ activeBasePath, activeBaseRegex, @@ -35,9 +48,7 @@ export default function NavbarNavLink({ useEffect(() => { const getData = async () => { - const cachedGithubStars = JSON.parse( - sessionStorage.getItem(GITHUB_STARS_SESSION_STORAGE_NAME), - ) as unknown as GithubStarsSessionStorage; + const cachedGithubStars = readCachedGithubStars(); try { if (cachedGithubStars) { const cacheExpiryTime = new Date(cachedGithubStars.retrievedTime); diff --git a/tsconfig.json b/tsconfig.json index 70adc9a9e5..1cf658b1ba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,8 +7,8 @@ "@features/*": ["src/features/*"], "@static/*": ["static/*"] }, - "module": "Node16", - "moduleResolution": "Node16", - "jsx": "react" + "jsx": "react-jsx", + "strict": false, + "ignoreDeprecations": "6.0" } }