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.
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 to load TypeScript files, such as , when you run 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:
TypeScript 6 changed the defaults of these options:
strictis nowtrueby default. Setting it tofalsekeeps the TypeScript 5 behavior. Otherwise, your build may report new errors, such as implicitanytypes.typesis now[]by default, so TypeScript no longer loads the type packages innode_modules/@typesautomatically. Setting it to["*"]keeps the TypeScript 5 behavior. Otherwise, your build may report errors likeCannot 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:
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.