chore: upgrade to TypeScript 6.0.3 and clean up legacy patterns#1295
chore: upgrade to TypeScript 6.0.3 and clean up legacy patterns#1295curfew-marathon wants to merge 1 commit into
Conversation
WalkthroughUpgrades TypeScript from 5.9.3 to 6.0.3, updates ChangesTypeScript 6.0 upgrade and type safety
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: one or more packages not found in the registry. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Pull request overview
This PR upgrades the repo to TypeScript 6.0.3 and performs related type-driven cleanups to remove legacy TS5-era patterns (notably eliminating no-explicit-any suppressions and replacing require() usage under BrowserOnly with React.lazy/import()).
Changes:
- Bump TypeScript to 6.0.3, adjust
tsconfig.json(JSX runtime, explicitstrict: false, and TS6 deprecation bridge). - Replace
anyusage with more precise types (Record<string, unknown>,JsonValue,LottieAnimationData) across multiple viewers and animation data files. - Replace client-only
require()calls withReact.lazy+Suspenseunder existingBrowserOnlyguards.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Updates compiler options for TS6 (jsx runtime, strict pin, deprecation bridge). |
| src/theme/NavbarItem/NavbarNavLink.tsx | Adds a cache-reading helper for GitHub stars sessionStorage data. |
| src/pages/api/service.tsx | Converts Swagger UI loading to React.lazy + Suspense under BrowserOnly. |
| src/components/icons/animations/types.ts | Introduces shared LottieAnimationData type. |
| src/components/icons/animations/open.lottie.ts | Replaces any Lottie export type with LottieAnimationData. |
| src/components/icons/animations/model.lottie.ts | Replaces any Lottie export type with LottieAnimationData. |
| src/components/icons/animations/fast.lottie.ts | Replaces any Lottie export type with LottieAnimationData. |
| src/components/icons/animations/community.lottie.ts | Replaces any Lottie export type with LottieAnimationData. |
| src/components/icons/animations/code.lottie.ts | Replaces any Lottie export type with LottieAnimationData. |
| src/components/icons/animations/auth0.lottie.ts | Replaces any Lottie export type with LottieAnimationData. |
| src/components/icons/animations/AnimatedIcon.tsx | Switches Lottie Player loading from require() to React.lazy + Suspense. |
| src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx | Changes context typing from Record<string, any> to Record<string, unknown>. |
| src/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsx | Changes context typing from Record<string, any> to Record<string, unknown>. |
| src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx | Introduces JsonValue and threads it through request-body serialization typing. |
| src/components/Docs/SnippetViewer/CheckRequestViewer.tsx | Changes context typing from Record<string, any> to Record<string, unknown>. |
| src/components/Docs/SnippetViewer/BatchCheckRequestViewer.tsx | Changes context typing from Record<string, any> to Record<string, unknown>. |
| src/components/Docs/RelationshipTuples/Viewer.tsx | Changes condition context typing from Record<string, any> to Record<string, unknown>. |
| src/components/Docs/AuthorizationModel/SyntaxTransformer.ts | Replaces a cast-based check with a type guard for TypeDefinition handling. |
| package.json | Bumps TypeScript and simplifies typecheck/lint scripts. |
| package-lock.json | Locks TypeScript dependency update to 6.0.3. |
Comments suppressed due to low confidence (2)
src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx:31
pyValue()always appends a comma before the closing}for object values. Whenvalis an empty object ({}), this renders as{\n,\n}, which is invalid Python and will break generated snippets.
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';
if (Array.isArray(val)) {
src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx:48
goValue()currently treats arrays as generic objects (because it doesn’t checkArray.isArray) and always adds a trailing comma before the closing}for maps. This can produce invalid Go (e.g. for{}it rendersmap[string]interface{}{\n,\n}) and incorrect output for JSON arrays.
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) {
const pad = ' '.repeat(indent);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function readCachedGithubStars(): GithubStarsSessionStorage | null { | ||
| 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; | ||
| } |
| import * as React from 'react'; | ||
| import { lazy, Suspense } from 'react'; |
| import * as React from 'react'; | ||
| import { lazy, Suspense } from 'react'; |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx (1)
15-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign
contextwith the JSON serialization contract.
Record<string, unknown>still allows non-serializable values. PreferRecord<string, JsonValue>so this option matches the existing request/snippet serialization model and avoids unsafe values leaking into generated payloads.♻️ Proposed change
+type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }; + interface ListUsersRequestViewerOpts { @@ - context?: Record<string, unknown>; + context?: Record<string, JsonValue>; expectedResults: ListUsersResponse;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx` at line 15, The `context` field in `ListUsersRequestViewer` is too permissive for the JSON serialization model and can admit non-serializable values. Update the `context` type to use the same JSON-safe value type as the existing request/snippet serialization contract (for example, `Record<string, JsonValue>`), and make sure the relevant `ListUsersRequestViewer` prop/interface type references that shared JSON type consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx`:
- Around line 9-11: Serializer handling for JsonValue is incomplete in jsValue,
pyValue, goValue, javaValue, and csharpValue: null and array inputs are not
consistently converted into valid target-language literals. Update each
serializer to explicitly handle null and arrays from the shared JsonValue type,
ensuring the emitted snippets use the correct language-specific representation
and remain syntactically valid for every supported JsonValue case.
In `@src/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsx`:
- Line 13: Snippet generation is still treating the ListObjectsRequestViewer
context values as strings even though context now allows non-string JSON-like
values. Update the snippet serializer logic in ListObjectsRequestViewer (and any
shared snippet generation helper it uses) to emit booleans, numbers, and objects
as proper JSON values instead of quoted strings, or tighten the context type
back to strings if that is the only supported shape. Use the context prop and
any serializer/formatter methods connected to snippet output as the entry points
for the fix.
In `@src/theme/NavbarItem/NavbarNavLink.tsx`:
- Around line 16-23: `readCachedGithubStars()` can throw before `getData()`
reaches its existing fallback handling, so wrap the sessionStorage read and
JSON.parse inside the same guarded flow used by `getData()`. Update
`readCachedGithubStars` (or move its call into `getData`) so storage access and
cache parsing failures are caught and return null, preserving the effect’s
fallback path and preventing uncaught errors from escaping.
---
Nitpick comments:
In `@src/components/Docs/SnippetViewer/ListUsersRequestViewer.tsx`:
- Line 15: The `context` field in `ListUsersRequestViewer` is too permissive for
the JSON serialization model and can admit non-serializable values. Update the
`context` type to use the same JSON-safe value type as the existing
request/snippet serialization contract (for example, `Record<string,
JsonValue>`), and make sure the relevant `ListUsersRequestViewer` prop/interface
type references that shared JSON type consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dc053c79-81cd-4c22-9f7f-98ac35de6f60
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (19)
package.jsonsrc/components/Docs/AuthorizationModel/SyntaxTransformer.tssrc/components/Docs/RelationshipTuples/Viewer.tsxsrc/components/Docs/SnippetViewer/BatchCheckRequestViewer.tsxsrc/components/Docs/SnippetViewer/CheckRequestViewer.tsxsrc/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsxsrc/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsxsrc/components/Docs/SnippetViewer/ListUsersRequestViewer.tsxsrc/components/icons/animations/AnimatedIcon.tsxsrc/components/icons/animations/auth0.lottie.tssrc/components/icons/animations/code.lottie.tssrc/components/icons/animations/community.lottie.tssrc/components/icons/animations/fast.lottie.tssrc/components/icons/animations/model.lottie.tssrc/components/icons/animations/open.lottie.tssrc/components/icons/animations/types.tssrc/pages/api/service.tsxsrc/theme/NavbarItem/NavbarNavLink.tsxtsconfig.json
| type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }; | ||
|
|
||
| function jsValue(val: JsonValue, indent: number): string { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Serializer coverage is incomplete for declared JsonValue inputs.
JsonValue includes null and arrays, but pyValue/goValue/javaValue/csharpValue don’t consistently emit valid literals for those cases, so some generated snippets become invalid or semantically wrong.
💡 Suggested fix
function pyValue(val: JsonValue, indent: number): string {
+ if (val === null) return 'None';
if (typeof val === 'string') return `"${val}"`;
if (typeof val === 'number') return String(val);
if (typeof val === 'boolean') return val ? 'True' : 'False';
@@
function goValue(val: JsonValue, indent: number): string {
+ if (val === null) return 'nil';
if (typeof val === 'string') return `"${val}"`;
if (typeof val === 'number' || typeof val === 'boolean') return String(val);
+ if (Array.isArray(val)) {
+ const items = val.map((v) => goValue(v, indent + 4));
+ return `[]interface{}{${items.join(', ')}}`;
+ }
if (typeof val === 'object' && val !== null) {
@@
function javaValue(val: JsonValue, indent: number): string {
+ if (val === null) return 'null';
if (typeof val === 'string') return `"${val}"`;
if (typeof val === 'number' || typeof val === 'boolean') return String(val);
+ if (Array.isArray(val)) {
+ const items = val.map((v) => javaValue(v, indent + 4));
+ return `List.of(${items.join(', ')})`;
+ }
if (typeof val === 'object' && val !== null) {
@@
function csharpValue(val: JsonValue, indent: number): string {
+ if (val === null) return 'null';
if (typeof val === 'string') return `"${val}"`;
if (typeof val === 'number' || typeof val === 'boolean') return String(val).toLowerCase();
+ if (Array.isArray(val)) {
+ const items = val.map((v) => csharpValue(v, indent + 4));
+ return `new[] { ${items.join(', ')} }`;
+ }
if (typeof val === 'object' && val !== null) {Also applies to: 27-27, 44-44, 56-56, 68-68
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/Docs/SnippetViewer/ExecuteApiRequestViewer.tsx` around lines 9
- 11, Serializer handling for JsonValue is incomplete in jsValue, pyValue,
goValue, javaValue, and csharpValue: null and array inputs are not consistently
converted into valid target-language literals. Update each serializer to
explicitly handle null and arrays from the shared JsonValue type, ensuring the
emitted snippets use the correct language-specific representation and remain
syntactically valid for every supported JsonValue case.
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| context?: Record<string, any>; | ||
| context?: Record<string, unknown>; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
context now accepts non-string values, but snippet generation still stringifies them incorrectly.
Several SDK branches quote context values as strings, so booleans/numbers/objects are emitted incorrectly (e.g., "true", "[object Object]"). Align generation with JSON-value-aware serializers, or narrow the type if only strings are supported.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/Docs/SnippetViewer/ListObjectsRequestViewer.tsx` at line 13,
Snippet generation is still treating the ListObjectsRequestViewer context values
as strings even though context now allows non-string JSON-like values. Update
the snippet serializer logic in ListObjectsRequestViewer (and any shared snippet
generation helper it uses) to emit booleans, numbers, and objects as proper JSON
values instead of quoted strings, or tighten the context type back to strings if
that is the only supported shape. Use the context prop and any
serializer/formatter methods connected to snippet output as the entry points for
the fix.
| function readCachedGithubStars(): GithubStarsSessionStorage | null { | ||
| 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; | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Guard cache parsing/storage access so errors don’t escape getData().
readCachedGithubStars() can throw (invalid JSON or storage access), and it’s called before the try block in getData(). That bypasses your fallback path and can break the effect flow.
🛡️ Proposed fix
function readCachedGithubStars(): GithubStarsSessionStorage | null {
- const raw = sessionStorage.getItem(GITHUB_STARS_SESSION_STORAGE_NAME);
- if (!raw) {
+ try {
+ const raw = sessionStorage.getItem(GITHUB_STARS_SESSION_STORAGE_NAME);
+ if (!raw) {
+ return null;
+ }
+ const parsed: unknown = JSON.parse(raw);
+ if (
+ typeof parsed === 'object' &&
+ parsed !== null &&
+ typeof (parsed as { count?: unknown }).count === 'number' &&
+ typeof (parsed as { retrievedTime?: unknown }).retrievedTime === 'number'
+ ) {
+ return parsed as GithubStarsSessionStorage;
+ }
return null;
+ } catch {
+ return null;
}
- const parsed = JSON.parse(raw);
- return typeof parsed?.count === 'number' && typeof parsed?.retrievedTime === 'number' ? parsed : null;
}Also applies to: 47-47
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/theme/NavbarItem/NavbarNavLink.tsx` around lines 16 - 23,
`readCachedGithubStars()` can throw before `getData()` reaches its existing
fallback handling, so wrap the sessionStorage read and JSON.parse inside the
same guarded flow used by `getData()`. Update `readCachedGithubStars` (or move
its call into `getData`) so storage access and cache parsing failures are caught
and return null, preserving the effect’s fallback path and preventing uncaught
errors from escaping.
Summary
Upgrades TypeScript from 5.9.3 → 6.0.3 (latest stable) and clears out the TS5-era patterns surfaced by the transition release. The goal was a clean upgrade with no strict-mode migration and no legacy
mess left behind — all @typescript-eslint/no-explicit-any suppressions are now gone from src.
No dependency bumps beyond typescript itself were required: @typescript-eslint 8.61.1 already declares support for typescript <6.1.0, and @tsconfig/docusaurus 2.0.9 is already the latest.
Configuration changes
A full strict migration was intentionally out of scope for this PR.
bridge.
Code cleanup (no behavior change)
readCachedGithubStars helper in NavbarNavLink.
The dynamic, variable-path require() in prism-include-languages.ts is intentionally retained — it's a legitimate synchronous side-effect import that ESM import() can't replace without changing
language-registration timing.
Test plan
chunks; ABAC conditions page still renders context values into snippets
Notes for reviewers
Summary by CodeRabbit
Bug Fixes
Chores