# Convert a SolidJS App From JavaScript to TypeScript

Yes. An agent converts a SolidJS app from JavaScript to TypeScript file by file, types its store and API layer, keeps the Rollup build working, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/convert-javascript-to-typescript/solidjs/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the build before it touches a source file. In an app like solidjs/solid-realworld, `package.json` has `solid-js` `^1.3.3`, `marked` `^0.8.0`, `rollup` `2.52.3` with `@rollup/plugin-babel`, `@rollup/plugin-node-resolve` and `@rollup/plugin-commonjs`, `babel-preset-solid` `^1.3.2`, no `typescript`, no lint setup beyond a `.prettierrc`, and a `test` script that is the single word `test`. `rollup.config.js` takes `src/index.js` as input, runs Babel with `presets: ["solid"]` and the optional chaining plugin, and resolves `.js` and `.jsx` only. The source is twenty-six JavaScript files: `src/App.js`, five components, six page modules under `src/pages/` and the store under `src/store/`, where `createAgent.js` wraps `fetch` calls to the RealWorld API and `index.js` builds a `createStore` state with getters over `createResource` results.

It adds `typescript`, `@babel/preset-typescript` and `@types/marked` as dev dependencies and writes a `tsconfig.json` with `strict`, `noEmit`, `jsx: "preserve"`, `jsxImportSource: "solid-js"` and `allowJs` on, so `tsc --noEmit` passes over the mixed tree during the migration. In `rollup.config.js` the input becomes `src/index.tsx`, the Babel plugin gets `extensions` for `.ts` and `.tsx` with the TypeScript preset added so types are stripped before the Solid JSX transform, and the resolve plugin's `extensions` list grows the same way. The build stays on Rollup and Babel; nothing moves to another bundler.

Then it renames and types one module at a time, store first. `src/store/createRouteHandler.js` has no JSX and becomes `.ts`; `src/store/index.js` renders two context providers and becomes `.tsx`. A new `src/types.ts` declares `Article`, `Comment`, `Profile` and `User` from the shapes `createAgent.js` sends and reads (`slug`, `favorited`, `favoritesCount`, `token`), and the store's `[state, actions]` tuple gets a type so `useStore()` stops returning `any`. One trap is specific to this codebase: `src/App.js` uses `Show`, `Suspense`, `Switch` and `Match` without importing them, because `babel-preset-solid` auto-imports those ten built-in components. `tsc` does not know that, so the agent adds explicit imports from `solid-js` where a file relies on it, which Babel accepts unchanged. Props objects on components such as `NavLink` get interfaces, and `getParams()?.routeName` keeps its optional chaining with a typed return.

Each step is checked with `npx tsc --noEmit` and `npm run build`, and the agent keeps the number of `any` and `@ts-expect-error` markers it had to leave listed in the pull request. When every file is converted it turns `allowJs` off, so a stray `.js` file cannot reappear unnoticed, and reads `.github/workflows/gh-pages.yml`, which installs on Node 14 and runs `npm run build`, to say whether the Node version there needs raising for the TypeScript version it added. The `test` script is left as it is and named as a gap, since there is no test runner to convert.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Convert this SolidJS app from JavaScript to TypeScript without changing its behaviour or its Rollup build. Read package.json, rollup.config.js, public/index.html, every file under src/ and the GitHub Pages workflow first. Add typescript, @babel/preset-typescript and the type packages the dependencies need, write a strict tsconfig.json with jsx preserve and jsxImportSource solid-js, and extend rollup.config.js so Babel and node-resolve handle .ts and .tsx. Rename files to .ts or .tsx depending on whether they contain JSX, starting with the store, declare the Article, Comment, Profile and User types from the API calls in createAgent, type the store tuple and every component's props, and add explicit solid-js imports for the built-in components the Babel preset was auto-importing. Run npx tsc --noEmit and npm run build after each module, turn allowJs off when nothing is left, list any remaining any or ts-expect-error, note whether the workflow's Node version needs raising, and open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on its own branch with the twenty-six source files renamed to `.ts` or `.tsx` and typed, a new `src/types.ts`, a `tsconfig.json`, the extended `rollup.config.js`, and `package.json` plus `package-lock.json` with the new dev dependencies. `public/index.html`, `.prettierrc` and the deploy workflow are unchanged unless the pull request says why.

The description lists each module in the order it was converted, the types it introduced and where they are used, every `any` or `@ts-expect-error` that remains with a reason, and the last `tsc --noEmit` and `npm run build` output. The full sequence of checks is in the transcript at `GET /o/{org}/sessions/{id}/messages`.

Before merging, a reviewer reads `src/types.ts` against the API the app actually calls, runs `npm start` once to click through the article, editor and settings routes, and decides whether to raise the workflow's Node version in the same pull request or a separate one. A follow-up message to the same session can tighten a type the reviewer thinks is too loose.

## Run it on every terminal hand-off

A developer who has been meaning to do this conversion for months starts it from the terminal with this body and goes back to feature work. The run happens in its own sandbox against the branch the request names, so nothing on the laptop changes until the pull request is read.

Send a `request_id`, a UUID, with the body so a retried start returns the run it already began instead of a second conversion of the same branch. The run's `GET /o/{org}/sessions/{id}` answer carries the pull request once it is open.

## Why run it on Rush?

A JavaScript to TypeScript conversion is a long chain of small renames, each of which can break the build in a way that only shows after the next five. The agent does the chain in a sandbox with the repository's own Rollup and Babel installed, runs `tsc` and the build after every module, and records each run, so a reviewer gets a finished branch rather than a half-migrated working tree.

The pull request carries the proof: the type checker's final output, the build's final output and the explicit list of what it could not type cleanly. Several apps can be converted at once, each in its own sandbox, with one pull request each.

## Frequently asked questions

### Will the build switch to Vite or another bundler?

No. The task is TypeScript, not a bundler change, so Rollup 2 and `@rollup/plugin-babel` stay and only learn the new extensions and the TypeScript preset. A bundler move is a separate run with its own pull request.

### Why do some files need imports they did not have before?

`babel-preset-solid` auto-imports `For`, `Show`, `Switch`, `Match`, `Suspense`, `SuspenseList`, `Portal`, `Index`, `Dynamic` and `ErrorBoundary` when it sees them in JSX, which is why `src/App.js` compiles today without importing them. TypeScript checks names before Babel runs, so it reports each of them as a name it cannot find; an explicit import from `solid-js` satisfies both.

### How strict will the types be?

`strict` is on from the first commit. Where the API returns a shape the agent cannot pin down from the code, it uses a narrow `unknown` and a comment rather than `any`, and every `any` or `@ts-expect-error` it does leave is listed in the pull request so the reviewer can decide what to tighten.

### What about the test script?

The repository's `test` script is a placeholder with no runner behind it, so there is nothing to convert. The agent says so and leaves it, and the type checker and build are the checks the pull request stands on.

## More SolidJS jobs

- [Migrate a SolidJS App from Rollup to Vite](https://getrush.ai/run/migrate-rollup-to-vite/solidjs/)
- [Migrate a Hand-Rolled Hash Router to @solidjs/router in a SolidJS App](https://getrush.ai/run/migrate-to-solid-router/solidjs/)
- [Upgrade npm Dependencies in a SolidJS App](https://getrush.ai/run/upgrade-npm-dependencies/solidjs/)

## The same job on other stacks

- [Convert a SvelteKit App from JavaScript to TypeScript](https://getrush.ai/run/convert-javascript-to-typescript/sveltekit/)
- [Convert a Vue App From JavaScript to TypeScript](https://getrush.ai/run/convert-javascript-to-typescript/vue/)
- [Convert a Chrome Extension From JavaScript to TypeScript](https://getrush.ai/run/convert-javascript-to-typescript/chrome-extension/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
