7.5. Use TypeScript 6 and 7

In this chapter, you'll learn how to configure your Medusa application or plugin to use TypeScript 6 or TypeScript 7.

TypeScript Version Support#

Medusa applications and plugins use TypeScript 5 by default. You can upgrade them to TypeScript 6 or TypeScript 7, but you need to update your tsconfig.json because TypeScript 6 changed some default compiler options.

Note: Support for TypeScript 7 is available since Medusa v2.22.4.

Step 1: Install TypeScript#

To use TypeScript 6, install it as a development dependency:

To use TypeScript 7, install it along with the @typescript/typescript6 package:

TypeScript 7 doesn't expose a compiler API. So, Medusa uses @typescript/typescript6 to load TypeScript files, such as medusa-config.ts, when you run medusa commands. If the package isn't installed, the Medusa CLI shows an error asking you to install it.


Step 2: Update tsconfig.json#

Next, update the compilerOptions in your application's or plugin's tsconfig.json:

tsconfig.json
{
  "compilerOptions": {
    // other options...
    "strict": false,
    "types": ["*"]
  }
}

TypeScript 6 changed the defaults of these options:

  • strict is now true by default. Setting it to false keeps the TypeScript 5 behavior. Otherwise, your build may report new errors, such as implicit any types.
  • types is now [] by default, so TypeScript no longer loads the type packages in node_modules/@types automatically. Setting it to ["*"] keeps the TypeScript 5 behavior. Otherwise, your build may report errors like Cannot find name 'describe' in your test files.

Remove baseUrl#

TypeScript 6 deprecates the baseUrl option, and TypeScript 7 removes it. If your tsconfig.json or src/admin/tsconfig.json sets baseUrl, remove it and make sure the paths in paths are relative to the tsconfig.json file:

tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Learn more about configuring aliases in the Type Aliases chapter.


Step 3: Test the Configurations#

To verify that your application or plugin builds with the new TypeScript version, run the build command:

If the build succeeds without new type errors, your project is ready to use the new TypeScript version.

Was this chapter helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵