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

  1. Drop the `--typescript` flag and let swizzle eject in JavaScript: `docusaurus swizzle <theme> <component>`.
  2. Switch to a theme that ships TypeScript sources (e.g. `@docusaurus/theme-classic`).
  3. 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

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


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/026b7dc83b5f2717. Report an issue: GitHub.