fix(frontend): remove test types from base tsconfig for CI build

The base tsconfig.json had types: ["vitest/globals", "@testing-library/jest-dom/vitest"]
which are devDependencies only installed during development. CI production
builds with npm ci --production don't include these, causing TS2688 errors.

Solution:

Remove types array from tsconfig.json (let TS auto-discover available types)
Simplify tsconfig.build.json to only exclude test files
Add triple-slash type references to test setup file
Add typecheck config to vitest.config.ts
This ensures:

Production builds work without devDependencies
Test files still have proper type definitions
No JSX.IntrinsicElements errors from missing React types
This commit is contained in:
GitHub Actions
2026-01-25 21:26:47 +00:00
parent 8612aa52e1
commit 0cd93ceb79
18 changed files with 111 additions and 91 deletions

View File

@@ -1,10 +1,16 @@
/// <reference types="vitest/globals" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference types="@testing-library/jest-dom/vitest" />
// Import jest-dom matchers at runtime to extend expect()
import '@testing-library/jest-dom/vitest'
// Ensure React's act environment flag is set for React 18+ to avoid warnings
// This must be set before importing testing utilities.
// See: https://github.com/facebook/react/issues/24560#issuecomment-1021997243
declare global { var IS_REACT_ACT_ENVIRONMENT: boolean | undefined }
globalThis.IS_REACT_ACT_ENVIRONMENT = true
import '@testing-library/jest-dom/vitest'
import { cleanup } from '@testing-library/react'
import { afterEach, vi } from 'vitest'
@@ -17,11 +23,10 @@ vi.mock('react-i18next', async () => {
// Helper to get nested translation value by dot-notation key
function getTranslation(key: string): string {
const keys = key.split('.')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let result: any = enTranslations
let result: unknown = enTranslations
for (const k of keys) {
if (result && typeof result === 'object' && k in result) {
result = result[k]
if (result && typeof result === 'object' && k in (result as Record<string, unknown>)) {
result = (result as Record<string, unknown>)[k]
} else {
// Key not found, return the key itself
return key