2 Commits

Author SHA1 Message Date
root 6de0690b76 Fix the admin TypeScript error
Test / Type Check (all packages) (push) Successful in 25s
Test / API Unit Tests (push) Failing after 24s
Test / Homepage Unit Tests (push) Failing after 18s
Test / Storefront Unit Tests (push) Successful in 17s
Test / Admin Unit Tests (push) Successful in 16s
Test / Dashboard Unit Tests (push) Successful in 17s
Test / API Integration Tests (push) Successful in 34s
Build & Deploy / Build & Push Docker Image (push) Successful in 54s
Build & Deploy / Deploy to VPS (push) Successful in 3s
2026-06-28 16:07:31 -04:00
root 0c9f3f8635 fix: resolve TS18046 errors for React 19 element props type
React 19 types React.ReactElement props as unknown instead of any. Test
helper functions that access element.props.children, .className, or .href
need explicit props type parameters on React.ReactElement and isValidElement.

Changes:
- admin/PublicShell.test.ts: add WithChildren type, use React.ReactElement<WithChildren>
- dashboard/PublicShell.test.ts: same pattern for childTypes and contentWrapper
- dashboard/StatCard.test.ts: add ElementWithClass type for className access
- dashboard/public-auth-pages.test.ts: add ElementWithHref type for href access

No any, @ts-ignore, or type assertion bypass used.
2026-06-28 01:21:36 -04:00
5 changed files with 136 additions and 8 deletions
@@ -6,7 +6,9 @@ vi.mock('@/components/PublicFooter', () => ({ default: function MockAdminFooter(
import PublicShell from './PublicShell'
function childTypes(node: React.ReactElement): string[] {
type WithChildren = { children?: React.ReactNode }
function childTypes(node: React.ReactElement<WithChildren>): string[] {
return React.Children.toArray(node.props.children).filter(isValidElement).map((child) => {
const type = child.type as any
if (typeof type === 'string') return type
@@ -19,10 +19,12 @@ function collectText(node: unknown): string[] {
return [];
}
type ElementWithHref = { children?: React.ReactNode; href?: string; embedded?: boolean }
function findElement(
node: unknown,
predicate: (element: React.ReactElement) => boolean,
): React.ReactElement | null {
predicate: (element: React.ReactElement<ElementWithHref>) => boolean,
): React.ReactElement<ElementWithHref> | null {
if (node === null || node === undefined || typeof node === "boolean")
return null;
if (Array.isArray(node)) {
@@ -32,7 +34,7 @@ function findElement(
}
return null;
}
if (!isValidElement<{ children?: React.ReactNode }>(node)) return null;
if (!isValidElement<ElementWithHref>(node)) return null;
if (predicate(node)) return node;
return findElement(node.props.children, predicate);
}
@@ -6,7 +6,9 @@ vi.mock('@/components/layout/PublicFooter', () => ({ default: function MockPubli
import PublicShell from './PublicShell'
function childTypes(node: React.ReactElement): string[] {
type WithChildren = { children?: React.ReactNode }
function childTypes(node: React.ReactElement<WithChildren>): string[] {
return React.Children.toArray(node.props.children).filter(isValidElement).map((child) => {
const type = child.type as any
if (typeof type === 'string') return type
@@ -26,7 +28,7 @@ describe('dashboard PublicShell', () => {
const shell = PublicShell({ embedded: true, children: React.createElement('main', { id: 'content' }) })
expect(childTypes(shell)).toEqual(['div'])
const contentWrapper = React.Children.toArray(shell.props.children).find(isValidElement) as React.ReactElement
const contentWrapper = React.Children.toArray(shell.props.children).find(isValidElement) as React.ReactElement<WithChildren>
expect(contentWrapper.props.children).toEqual(React.createElement('main', { id: 'content' }))
})
})
@@ -11,10 +11,12 @@ function collectText(node: unknown): string[] {
return []
}
function collectElements(node: unknown): React.ReactElement[] {
type ElementWithClass = { children?: React.ReactNode; className?: string }
function collectElements(node: unknown): React.ReactElement<ElementWithClass>[] {
if (node === null || node === undefined || typeof node === 'boolean') return []
if (Array.isArray(node)) return node.flatMap(collectElements)
if (!isValidElement<{ children?: React.ReactNode }>(node)) return []
if (!isValidElement<ElementWithClass>(node)) return []
return [node, ...collectElements(node.props.children)]
}
+120
View File
@@ -15427,6 +15427,126 @@
"devDependencies": {
"typescript": "^5.4.0"
}
},
"node_modules/@next/swc-darwin-arm64": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.2.8.tgz",
"integrity": "sha512-R/MDVX4Cj+bzvTNkDWNyA09yCPBZB0J1m8P3VAmWAzx/J7DctA1wxya1LU3CcPv2szER3AImHEtsgScauH8SsQ==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-darwin-x64": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.2.8.tgz",
"integrity": "sha512-XH2u8C/meLJmEZbN0G5MRZp8tvxBz5KQ+xv4vX34zL8gL3//5qkc5M/aLsvNAfg5/KbcjIVe3h6aiO0wJcNWKA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.2.8.tgz",
"integrity": "sha512-zyA8bCtlAXOzZD6ri6hIi5Z7hW5+07ea81KK0xdezmJHrbrAgvwIRd6VbkddJTapmZVSmWzbpAdYoi1HZNF7KA==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.2.8.tgz",
"integrity": "sha512-MWIALcC/R12KNHTAliyX96XwwnHLGNKRJHsaFiGKE0fF9sEoXHUlxvdrrl3iQfIKWfBcNdQ9rrMYHc1qFGc71A==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-gnu": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.2.8.tgz",
"integrity": "sha512-SD/R9QU6+wUB3lH6InhOLu1eP3wle4sSjsNdMwk24yFwaWUB5TAtscvFbOqh1AYBsJvHRez3tYHETfbBFd4dRg==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-x64-musl": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.2.8.tgz",
"integrity": "sha512-F1Al3cRKhYR7/V1RaXnHceqilNLFDe47w7Li/Asph1SklaHHm/b2FahLar2nWct9l9K143NlqbAUFQMjx30QYA==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-arm64-msvc": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.2.8.tgz",
"integrity": "sha512-LxhCLToY0id1CkmYFi9sTM2RfoBWszr6mmMrBtmTFqKF0fXX3ZIbM8m1sKoNFIrZFn7gFroT7cnZea5neufSHg==",
"cpu": [
"arm64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-win32-x64-msvc": {
"version": "16.2.8",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.2.8.tgz",
"integrity": "sha512-xfGxs1zIkTOLzH8i1WWCeTqQhNqyrv3aVT55PMy7Ul3dfxlA3In7hNEJ3Uo2qpalEBOlkG6G6FLRMWbUrxL+qQ==",
"cpu": [
"x64"
],
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
}
}
}