Programming

TypeScript 7.1 RC: Test the New Compiler Against a Project Without Replacing Your Stable Version

Install TypeScript 7.1 RC in a dedicated Git worktree, run your project’s existing checks, and keep the stable checkout available as a baseline.

You want to find out whether TypeScript 7.1 RC works with your project, but you do not want to change the compiler your team relies on. A practical way to separate the experiment is to create a second checkout with Git worktrees, install the release candidate there, and run the checks your project already uses.

The TypeScript team’s 7.1 RC announcement provides this npm command:

npm install -D typescript@rc

It changes dependency metadata in the directory where you run it. Use it in the test worktree, not your stable checkout. The announcement establishes that the release candidate is available through the rc tag; it does not promise that every project will compile unchanged or that every feature mentioned in the post is ready for your runtime and bundler.

This tutorial takes you through a controlled compatibility test: establish a baseline, create an isolated worktree, install the RC, run representative project checks, and preserve or remove the experiment deliberately. It focuses on the project’s actual behavior rather than trying to cover every change in the release.

What the experiment isolates

A Git worktree gives you another working directory attached to the same repository. You can check out a separate branch there while leaving your existing checkout on its current branch. The RC installation and any test-only edits then stay in that second directory.

flowchart TD
    A["Stable project checkout"] --> B["Create test worktree"]
    B --> C["Install TypeScript 7.1 RC"]
    C --> D["Run project checks"]
    D --> E["Review and record results"]
    E --> F["Keep or remove experiment"]

The diagram separates the action you take from the result you observe. You control where the RC dependency is installed. Whether a project check passes is an outcome to record, not something the release announcement guarantees.

A worktree is not a substitute for a backup of uncommitted files. It is another working directory in the same repository. Start from a known commit, and keep any unrelated work safe before beginning.

1. Establish a baseline in the stable checkout

From your current project directory, inspect the working tree:

git status --short

If this prints changes, decide how to protect them before continuing. Commit them, or use another safe copy of the work. The test branch should begin from a commit you can identify, rather than mixing existing edits with the compiler trial.

Record the current branch and inspect the project’s dependency declaration:

git branch --show-current
cat package.json

Look for typescript under devDependencies, and identify the lockfile your project uses. The stable compiler version is whatever your project’s dependency declaration and lockfile specify; do not infer it from a globally installed tsc. A global executable may not be the one your project scripts resolve.

Write down a few baseline details before changing anything:

Detail What to record
Starting commit The commit you will test
Current branch The branch in the stable checkout
TypeScript dependency The declared version and lockfile entry
Relevant checks The project’s type-check, build, and test commands
Existing local changes Whether the checkout was clean

This is more useful than recording only “it passed.” When you later compare outcomes, you need to know whether the source revision and checks were the same.

If the repository already has a branch or worktree for another task, choose a distinct branch name for this test. Git does not allow the same branch to be checked out in multiple worktrees at once.

2. Create a separate worktree and verify it

From the original checkout, create a new branch and worktree. Change the names if they are already in use:

git worktree add -b test/typescript-7-1-rc ../project-ts71-rc HEAD

This creates a branch at the current HEAD and checks it out in the sibling directory ../project-ts71-rc. Now move into that directory and confirm the location and branch:

cd ../project-ts71-rc
pwd
git branch --show-current
git status --short

Do this verification before installing anything. The point of the setup is to put the dependency change in the second checkout. If you run the install from the original directory, you are no longer testing in isolation.

For a repository with a package in a nested folder, first determine where its package manager expects the workspace root. Run the install and project scripts from the appropriate location inside the test worktree. Do not change the original checkout’s files as a shortcut to reach the nested package.

The new worktree begins at the commit you selected. If you need a different starting point, choose it deliberately and record it. Comparing a stable run from one revision with an RC run from another can make unrelated source changes look like compiler differences.

3. Install the RC only in the test worktree

From the test checkout’s project root, run the command published in the TypeScript announcement:

npm install -D typescript@rc

The command adds TypeScript as a development dependency using npm’s rc tag. Inspect the files it changes:

git status --short
git diff -- package.json package-lock.json

Your repository may use a different lockfile name. Review the actual diff and confirm that the dependency update is in the test worktree. If the install changes additional files, inspect them rather than assuming the changes are all part of the TypeScript update.

The supplied announcement documents the npm command, so use that exact command when your project uses npm. If you use another package manager, check its current documentation for the correct way to install a tagged prerelease; do not assume that its syntax or tag handling is identical. Avoid installing the RC globally for this project test, because that makes it less clear which compiler your local scripts are using.

If you use npm workspaces, run the command from the appropriate workspace root and check which package manifest and lockfile it updated. The important safeguard is not a particular directory name: it is verifying that the RC dependency change belongs to the test checkout and not the stable one.

4. Run the project’s real checks

Do not assume every repository has a script called typecheck. Inspect the scripts section of package.json and identify the commands your project normally uses. A project might define a command like this:

{
  "scripts": {
    "typecheck": "tsc --noEmit",
    "build": "your-existing-build-command",
    "test": "your-existing-test-command"
  }
}

This is an illustrative shape, not a prescription for your scripts. Use the commands already present in your repository. If a typecheck script exists, run it from the test worktree:

npm run typecheck

Then run the build and any tests that exercise TypeScript-dependent code paths, if those are part of your normal workflow. A type-check alone does not tell you whether your build tooling or tests work with the installed compiler. Conversely, a build that happens to pass may not exercise every type-checking or feature path your team cares about.

Record the exact command and its outcome. For example, note whether it exited successfully, the first diagnostic if it failed, and whether the failure is repeatable. Do not edit the stable branch to make the RC test pass. If a test-only source change is needed to explore a problem, make it in the test worktree and label it as an experimental change.

A useful comparison table is:

Check Stable checkout RC worktree
Starting commit Recorded commit Same starting commit
TypeScript dependency Existing declaration typescript@rc
Type-check command Exact command and result Exact command and result
Build command Exact command and result Exact command and result
Relevant tests Exact command and result Exact command and result

The table is a record, not a performance benchmark. The TypeScript announcement describes performance improvements since the beta, but this procedure does not establish a speedup for your particular project. If timing matters to your evaluation, use repeatable commands and comparable conditions, and keep timing separate from whether the build or check succeeds.

5. Try the feature your project actually uses

The RC announcement excerpt specifically describes support for import attributes in ambient modules. That is worth testing if your project has wildcard declarations for imported files, such as CSS or text, and imports them with attributes.

For example, the announcement shows an ambient declaration shape like this:

declare module "*.css" {
  const content: CSSStyleSheet;
  export default content;
}

It also gives an import-attribute example:

import someTheme from "./themes/someCoolTheme.css" with { type: "css" };

These snippets illustrate the TypeScript-side pattern described in the announcement. To test your project, inspect the declaration and a real import together, then run the project’s actual type-check command in the RC worktree. A small demonstration file can help isolate a compiler diagnostic, but the project’s own declaration files and configuration are the more relevant compatibility test.

Do not treat a successful type-check as proof that a browser, bundler, or runtime will load the file as expected. The announcement explains import attributes as metadata that runtimes and bundlers can use to interpret imports; TypeScript’s acceptance of source code does not, by itself, verify those other tools. Test the runtime or build path separately if that behavior is part of your project.

The announcement excerpt also mentions API refinements, content mapper improvements, --disableDynamicImportExtensionRewriting, and an experimental WebAssembly package. It does not provide enough detail in the supplied excerpt to specify their full behavior or configuration here. If one of those items is relevant, consult the full announcement and the applicable current documentation before designing a targeted test. Avoid adding a guessed compiler option to your configuration based only on its name.

For a general first pass, keep the question practical: can the project install the RC, and do the project checks you rely on behave as expected? If not, keep the complete diagnostic and reduce it to a small reproduction where possible. A failure is useful evidence, but it does not automatically tell you whether the cause is a compiler change, project configuration, or an interaction with another tool.

6. Compare the result with the stable checkout

Return to the original checkout in a separate terminal or after leaving the test worktree. Use its actual path:

cd /path/to/your/original/project
git branch --show-current
git status --short
git diff -- package.json package-lock.json

If the original checkout was clean before the experiment, it should still be clean. If you see changes, stop and inspect them; do not discard them blindly. You may simply have run a command from the wrong directory, or there may have been pre-existing edits you did not record.

For a meaningful comparison, use the same source commit and the project’s normal stable dependency resolution. The stable checkout’s dependency files are the reference; this tutorial does not prescribe a particular stable TypeScript version. If you need to rerun a check on the stable version, use the project’s normal workflow and keep its dependency files untouched.

A result can be classified more precisely than pass or fail:

  • Install problem: npm could not resolve or install the RC dependency.
  • Type-check difference: the project reports diagnostics under the RC that you did not observe in the stable baseline.
  • Build or test difference: a project command fails after installation, even if type-checking passes.
  • Feature-specific result: the pattern you intended to test behaves differently from the project’s baseline.

These categories do not diagnose the cause. They help you decide what evidence to preserve and what to investigate next.

7. Keep or remove the test worktree deliberately

If you have finished and do not need the branch, return to the original checkout and remove the test worktree:

cd /path/to/your/original/project
git worktree remove ../project-ts71-rc

If the test worktree contains uncommitted source changes, Git may refuse to remove it. Review and preserve useful diagnostics, reproductions, or edits before cleaning it up. Do not force removal simply to make the directory disappear.

If you want to keep the experiment, commit relevant test-only changes on the test branch or save your notes elsewhere before removing the directory. The RC dependency update should not reach the stable branch by accident. A passing test is evidence about the paths you checked; it is not itself a decision to adopt the release candidate.

What this test can—and cannot—tell you

This workflow gives you a controlled answer to a narrow question: can your project install TypeScript 7.1 RC in an isolated checkout, and what happens when you run its selected checks against that version? It also gives you a place to investigate a diagnostic without replacing the dependency files in your stable working copy.

It cannot establish that every editor, build system, runtime, or deployment environment will behave identically. Nor does the supplied announcement excerpt provide a complete migration guide for every 7.1 RC change. Record the commit, dependency update, commands, and results; verify feature-specific details against the full TypeScript announcement and relevant tooling documentation before changing the stable dependency.

The key safeguard is simple: install the RC only in the test worktree, compare the same project revision where possible, and make adoption a separate decision rather than a side effect of trying the compiler.

External Sources used for this article

Related Articles

View all →