diff --git a/packages/cli/src/commands/experimental/setupRscHandler.js b/packages/cli/src/commands/experimental/setupRscHandler.js index 12da132d7a65..aeb2d74ccd47 100644 --- a/packages/cli/src/commands/experimental/setupRscHandler.js +++ b/packages/cli/src/commands/experimental/setupRscHandler.js @@ -4,6 +4,7 @@ import path from 'path' import execa from 'execa' import { Listr } from 'listr2' +import { prettify } from '@redwoodjs/cli-helpers' import { getConfig, getConfigPath } from '@redwoodjs/project-config' import { errorTelemetry } from '@redwoodjs/telemetry' @@ -185,6 +186,27 @@ export const handler = async ({ force, verbose }) => { }) }, }, + { + title: 'Add React experimental types', + task: async () => { + const tsconfigPath = path.join(rwPaths.web.base, 'tsconfig.json') + const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf-8')) + + if (tsconfig.compilerOptions.types.includes('react/experimental')) { + return + } + + tsconfig.compilerOptions.types.push('react/experimental') + + writeFile( + tsconfigPath, + prettify('tsconfig.json', JSON.stringify(tsconfig, null, 2)), + { + overwriteExisting: true, + } + ) + }, + }, { title: 'Patch vite', task: async () => { diff --git a/packages/vite/ambient.d.ts b/packages/vite/ambient.d.ts index 82550d6c10c7..d2b450c857c6 100644 --- a/packages/vite/ambient.d.ts +++ b/packages/vite/ambient.d.ts @@ -1,5 +1,5 @@ /* eslint-disable no-var */ -/// +/// import type { HelmetServerState } from 'react-helmet-async' declare global { diff --git a/packages/vite/src/fully-react/assets.tsx b/packages/vite/src/fully-react/assets.tsx index 3695ddb48a18..6aa11011a68c 100644 --- a/packages/vite/src/fully-react/assets.tsx +++ b/packages/vite/src/fully-react/assets.tsx @@ -52,7 +52,6 @@ export function Assets() { // Do we also need special code for SSR? // if (isClient) return - // @ts-expect-error Need experimental types here for this to work return }