facebook/docusaurus · error
Theme name=${plugin.instance.name} does not support the code
Error message
Theme name=${plugin.instance.name} does not support the code=${'--typescript'} CLI option. What it means
Thrown by swizzle's `getLanguageForThemeName` when the user passes `--typescript` but the resolved theme plugin does not implement `getTypeScriptThemePath` (i.e. it has no TypeScript sources). Docusaurus will not synthesize TS files for a JS-only theme.
Source
Thrown at packages/docusaurus/src/commands/swizzle/index.ts:44
import type {SwizzleAction, SwizzleComponentConfig} from '@docusaurus/types';
import type {SwizzleCLIOptions, SwizzlePlugin} from './common';
import type {ActionResult} from './actions';
async function getLanguageForThemeName({
themeName,
plugins,
options,
}: {
themeName: string;
plugins: SwizzlePlugin[];
options: SwizzleCLIOptions;
}): Promise<'javascript' | 'typescript'> {
const plugin = getPluginByThemeName(plugins, themeName);
const supportsTS = !!plugin.instance.getTypeScriptThemePath?.();
if (options.typescript) {
if (!supportsTS) {
throw new Error(
logger.interpolate`Theme name=${
plugin.instance.name
} does not support the code=${'--typescript'} CLI option.`,
);
}
return 'typescript';
}
if (options.javascript) {
return 'javascript';
}
// It's only useful to prompt the user for themes that support both JS/TS
if (supportsTS) {
return askSwizzlePreferredLanguage();
}
return 'javascript';View on GitHub (pinned to 3f483e80e3)
Solutions
- Drop the `--typescript` flag and let swizzle eject in JavaScript: `docusaurus swizzle <theme> <component>`.
- Switch to a theme that ships TypeScript sources (e.g. `@docusaurus/theme-classic`).
- If you maintain the theme, implement `getTypeScriptThemePath` on the plugin and ship `.ts`/`.tsx` files.
Example fix
# before docusaurus swizzle my-js-theme Header --typescript # throws # after docusaurus swizzle my-js-theme Header
Defensive patterns
Strategy: type-guard
Validate before calling
const supportsTS = !!plugin.instance.getTypeScriptThemePath?.();
if (options.typescript && !supportsTS) {
throw new Error(`Theme ${plugin.instance.name} has no TS sources — drop --typescript`);
} Type guard
function themeSupportsTypeScript(plugin: any): boolean {
return typeof plugin?.instance?.getTypeScriptThemePath === 'function'
&& Boolean(plugin.instance.getTypeScriptThemePath());
} Try / catch
try { await getLanguageForThemeName({themeName, plugins, options}); }
catch (e) {
if (/does not support the.*--typescript/.test(e.message)) {
options.typescript = false; // fall back to JS
await getLanguageForThemeName({themeName, plugins, options});
} else throw e;
} Prevention
- Detect TS support programmatically before passing `--typescript`.
- Default to no language flag and let Docusaurus prompt.
- Document which themes ship TS sources in your project README.
When it happens
Trigger: Running `docusaurus swizzle <theme> <component> --typescript` where `<theme>` only ships JavaScript (its plugin instance has no `getTypeScriptThemePath`).
Common situations: Using a community theme that is JS-only; assuming the official `theme-classic` TS support applies to all themes; migrating a JS theme and forgetting it has no `.ts` sources.
Related errors
- No files to copy from path=${fromPath} with glob code=${glob
- Can't get component config: component doesn't exist: ${compo
- Swizzle config does not match expected schema: ${result.erro
- Theme ${themeName} not found
- Invalid package manager choice ${packageManager}. Must be on
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/026b7dc83b5f2717.
Report an issue: GitHub.