typescript-update
Skill1 starsChanged 6 days agoMITView on GitHub
Guidance for updating to the newer versions of TypeScript. Use this when you need to upgrade TypeScript or as part of a larger dependency update process.
- Installs packages
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- typescript-build-referencesSkill
- typescript-project-setupSkill
- typescript-strictSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 8 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Read every package.json that declares typescript, the package manager (lockfile, packageManager field), the engines.node range, and node …
- Distinctive: line 16
Run each of those scripts once, logging output, and note which pass and which fail.
- Distinctive: line 18
Read the version guides before your first edit: Always read 6to7.md. Also read 5to6.md if starting below 6.0, and 4to5.md if starting below …
- Distinctive: line 19
Choose the package layout: Run the API-consumer check in 6to7.md.
- Very specific: line 22
Do not install and build every intermediate major version.
- Very specific: line 29
Run installs, builds and tests non-interactively, with output redirected to a log file, e.g.
- Very specific: line 31
Never run commands that wait for input (e.g.
- Distinctive: line 32
Prefer upgrading a dependency over patching it.
- Distinctive: line 39
Do not paper over upgrade errors with suppression escape hatches.
- Very specific: line 41
Do not use ignoreDeprecations.
- Very specific: line 42
Do not add // @ts-ignore, // @ts-expect-error, or // @ts-nocheck to silence new errors.
- Very specific: line 43
Do not use any just to make an error go away.
- Very specific: line 44
Do not disable tsconfig.json strictness flags (strict, noImplicitAny, strictNullChecks, skipLibCheck, etc.)
- Distinctive: line 56
All versions of TypeScript may include updates to the DOM.
- Very specific: line 62
If you can't determine the correct fix, add a temporary ts-ignore comment to suppress the error so you can continue with the upgrade …
- Very specific: line 69
When you're done, remove the @ts-ignore part of the comment, but leave behind the explanation of why the code is wrong.
- Very specific: line 75
Check the package.json for any @types/ entries and update them to the latest version compatible with the corresponding core dependency.
- Very specific: line 81
Do a clean, lockfile-respecting install (e.g.
- Distinctive: line 96
Every gate that is still red, and why
- Distinctive: line 97
If you had to stop before reaching the latest version, explain what happened and what remains to be done
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- prettier-ignore-start -->Your role is to upgrade the project to the latest TypeScript version (7.x, or a later minor such as 7.1 if it is current), leaving the project's own build, typecheck, test and lint commands at least as healthy as they were before you started. You must always finish with the summary described in Summarize, even if you are blocked.
How To Upgrade
- Record the baseline (cheaply).
- Read every
package.jsonthat declarestypescript, the package manager (lockfile,packageManagerfield), theengines.noderange, andnode --version. - Identify the project's own
build,typecheck/check-types,testandlintscripts. - Reuse an existing
node_modulesif present. Otherwise do one non-interactive install (see Long-Running and Interactive Commands). Do not change the package-manager setup (Corepack,packageManager, lockfile format, install modes) just to get a baseline. - Run each of those scripts once, logging output, and note which pass and which fail.
- A red or uninstallable baseline is information to report, never a reason not to upgrade. Continue with the upgrade and compare against the baseline at the end.
- Read every
- Read the version guides before your first edit. Always read 6to7.md. Also read 5to6.md if starting below 6.0, and 4to5.md if starting below 5.0. Treat them as checklists of changes to apply up front, not as references to consult only after something breaks.
- Choose the package layout. Run the API-consumer check in 6to7.md. If anything in the project or its dependencies uses the TypeScript API, use the side-by-side layout (
typescriptaliased to@typescript/typescript6,@typescript/nativealiased totypescript@7) from the start. Otherwise install plaintypescript@7. - Apply all config changes in one pass. Edit
tsconfig*.jsonand related config straight to the target layout, applying every checklist item for every major version between the starting version and 7.0 (e.g.types,module/moduleResolution,baseUrl/paths,rootDir,esModuleInterop, removed options). Update@types/*and TypeScript-dependent tools (see@typesDependencies). - Install the target versions once, then typecheck with the new
tscand fix the errors.- Do not install and build every intermediate major version. At most, you may run one optional typecheck with TypeScript 6.0 (e.g.
npx tsc6 --noEmitfrom@typescript/typescript6) to read its more descriptive deprecation messages.
- Do not install and build every intermediate major version. At most, you may run one optional typecheck with TypeScript 6.0 (e.g.
- Run the Completion Gate, then Summarize.
Long-Running and Interactive Commands
Installs and builds in large repositories can take several minutes. Agent terminals may move a command to the background after a timeout; the command is still running.
- Run installs, builds and tests non-interactively, with output redirected to a log file, e.g.
CI=true yarn build > /tmp/ts-upgrade-build.log 2>&1; echo "exit=$?". Then read the tail of the log. - If the terminal tool reports that a command was moved to the background or timed out, keep polling its output (or the log file) until it exits. Do not end your turn while a command is still running, and never end a turn with an empty message.
- Never run commands that wait for input (e.g.
pnpm patchwithout--edit-dir,npxwithout-y,npm init, project generators,git rebase -i). If a prompt appears anyway, answer it immediately and finish the workflow it started in the same turn. - Prefer upgrading a dependency over patching it. If a dependency must be patched, persist the patch non-interactively and refresh the lockfile:
- pnpm:
pnpm patch <pkg>@<exact-version> --edit-dir /tmp/patch-<pkg>, edit the files there,pnpm patch-commit /tmp/patch-<pkg>(writespatches/andpatchedDependenciesand updates the lockfile), then verify withpnpm install --frozen-lockfile. - yarn (berry):
yarn patch <pkg>@npm:<exact-version>prints a folder; edit it, runyarn patch-commit -s <folder>, thenyarn install. - npm: edit
node_modules/<pkg>, runnpx -y patch-package <pkg>, and add a"postinstall": "patch-package"script.
- pnpm:
Forbidden Fixes
Do not paper over upgrade errors with suppression escape hatches. Specifically:
- Do not use
ignoreDeprecations. The target version will not support this option. - Do not add
// @ts-ignore,// @ts-expect-error, or// @ts-nocheckto silence new errors. - Do not use
anyjust to make an error go away. - Do not disable
tsconfig.jsonstrictness flags (strict,noImplicitAny,strictNullChecks,skipLibCheck, etc.)
Version-Specific Guidance
Additional files document version-specific changes and migration steps. Read the ones that apply before editing (see step 2 above):
- 4to5.md covers upgrading from 4.x to 5.0.
- 5to6.md covers upgrading from 5.x to 6.0.
- 6to7.md covers upgrading from 6.x to 7.0, including the TypeScript API compatibility layout and troubleshooting for tool-injected
baseUrl, the Node.js version required by the 7.0tsclauncher, and framework-generated tsconfigs.
Common Issues
All versions of TypeScript may include updates to the DOM. These are not specifically documented anywhere. Use your best judgment to determine how to fix these, keeping in mind that you should not be making runtime-affecting changes unless absolutely justified.
Usercode Bugs
Newer versions TypeScript may sometimes find unambiguous problems in the user's code that were not caught by previous versions.
Sometimes you will be able to easily determine the correct fix (i.e. what was intended).
If you can't determine the correct fix, add a temporary ts-ignore comment to suppress the error so you can continue with the upgrade process:
// @ts-ignore BUG: This is always a runtime error! Fix as appropriate depending on intended meaning
const p = "foo" in 42;When you're done, remove the @ts-ignore part of the comment, but leave behind the explanation of why the code is wrong.
Report all bugs you found in the summary.
@types Dependencies
You may need to update @types dependencies alongside the main TypeScript version.
Check the package.json for any @types/ entries and update them to the latest version compatible with the corresponding core dependency.
Completion Gate
The upgrade is not done until this gate has been run after your last edit:
- Do a clean, lockfile-respecting install (e.g.
npm ci,pnpm install --frozen-lockfile,yarn install --immutable). This provespackage.json, the lockfile and anypatchedDependenciesagree. - Confirm the installed compiler version, e.g.
npx tsc --version. - Rerun each baseline command (build, typecheck, test, lint), including tests, and compare each one against the baseline.
- Every command that passed in the baseline and fails now must be fixed, or reported in the summary as an explicit failure of the upgrade. Do not label it "out of scope". The upgrade is also not complete while the target
tscreports errors for the project, including errors from framework-generated tsconfigs.
Summarize
Your final message must always be this summary, even if you were blocked or stopped early:
- Starting TypeScript version
- Ending TypeScript version actually installed (from
tsc --versionor the lockfile), and the package layout used (plaintypescript@7or side-by-side with@typescript/typescript6) - Baseline vs. final result for each build, typecheck, test and lint command
- Any notable edits you had to make
- Bugs in usercode you found
- Offer to remove the
// @ts-ignorecomments you added
- Offer to remove the
- Every gate that is still red, and why
- If you had to stop before reaching the latest version, explain what happened and what remains to be done
<!-- prettier-ignore-end -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

