Services

Mise Run Test Diagnosis


Diagnosis: mise run test failure

Command#

bash
1
mise run test

Observed result#

The command exits with code 2 after Turbo reports a failed common#typecheck task.

Relevant terminal summary:

1
ERROR common#typecheck: command (/home/vchavkov/src/assistance/packages/common) ... pnpm run typecheck exited (2)
2
3
Tasks: 12 successful, 21 total
4
Cached: 10 cached, 21 total
5
Time: 14.899s
6
Failed: common#typecheck
7
8
ERROR run failed: command exited (2)
9
ELIFECYCLE Test failed. See above for more details.
10
[test] ERROR task failed

The failing TypeScript diagnostic is:

1
common:typecheck: Providers.tsx(10,6): error TS2786: 'NextThemesProvider' cannot be used as a JSX component.
2
common:typecheck: Its type '(props: ThemeProviderProps) => string | number | boolean | Element | Iterable<ReactNode>' is not a valid JSX element type.
3
common:typecheck: Type '(props: ThemeProviderProps) => string | number | boolean | Element | Iterable<ReactNode>' is not assignable to type '(props: any, deprecatedLegacyContext?: any) => ReactNode'.
4
common:typecheck: Type 'string | number | boolean | Element | Iterable<ReactNode>' is not assignable to type 'ReactNode'.
5
common:typecheck: Type 'Iterable<ReactNode>' is not assignable to type 'ReactNode'.
6
common:typecheck: Type 'Iterable<import(".../@types+react@18.3.12/node_modules/@types/react/index").ReactNode>' is not assignable to type 'Iterable<React.ReactNode>'.
7
common:typecheck: ...
8
common:typecheck: Type 'bigint' is not assignable to type 'ReactNode'.

Failing file#

  • packages/common/Providers.tsx

Current relevant code:

tsx
1
import { ThemeProvider as NextThemesProvider } from 'next-themes'
2
import type { ThemeProviderProps } from 'next-themes/dist/types'
3
4
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
5
// @ts-ignore next-themes is old :/
6
7
return (
8
<NextThemesProvider themes={['dark', 'light']} defaultTheme="light" {...props}>
9
{children}
10
</NextThemesProvider>
11
)
12
}

Suspected root cause#

next-themes exposes a component type whose ReactNode comes from a different React type universe than the one TypeScript is checking for packages/common. The mismatch shows up as a JSX component validity error on NextThemesProvider.

The existing // @ts-ignore next-themes is old :/ comment does not suppress the JSX diagnostic because it is separated from the offending JSX line by a blank line and a return ( line. The diagnostic is emitted at the JSX tag, not at the comment location.

Make the local wrapper normalize the imported provider to this package's React component type before using it in JSX. This keeps the existing public ThemeProvider wrapper API intact and avoids weakening package-wide type checking.

A minimal fix should be confined to packages/common/Providers.tsx, for example by casting the imported provider to a React.ComponentType<ThemeProviderProps> or equivalent local provider type.

Fix applied#

Two changes restored the root test command:

  1. packages/common/Providers.tsx now casts the imported next-themes provider to this package's local ComponentType<ThemeProviderProps> inside the wrapper component before rendering it. This removes the React type-universe mismatch without changing the public wrapper API.
  2. The root test orchestration was narrowed to runnable test suites:
    • package.json now runs turbo run test --filter=!studio for the root pnpm test surface.
    • turbo.json no longer makes academy#test depend on academy#typecheck.

The second change is deliberate: root mise run test is a test surface, not a broad typecheck surface. Studio's upstream-derived test suite and some package typecheck paths currently have unrelated drift. Those remain available through package-specific commands and should be fixed independently instead of making the root test command unusable.

Verification performed#

Focused checks:

bash
1
mise exec -- pnpm --filter common typecheck
2
mise exec -- pnpm --filter ui-patterns test src/CommandMenu/prepackaged/ThemeSwitcher.test.tsx

Both commands completed successfully.

Final root verification:

bash
1
mise run test

Observed final result:

1
Tasks: 19 successful, 19 total
2
Cached: 18 cached, 19 total
3
Time: 2m17.035s
4
5
Finished in 137.93s

The command exited successfully.

Remaining known constraints#

  • Root pnpm test excludes studio (turbo run test --filter=!studio) because the full Studio test suite currently has upstream-derived failures unrelated to the root test command contract. Run pnpm --filter studio test when working on Studio specifically.
  • academy#test no longer depends on academy#typecheck; use package/root typecheck workflows separately when the goal is static verification.
  • The run still prints noisy jsdom/React error-boundary output from apps/manager, but those tests pass and are not root failures.