docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

The `fromExtensions` and `toExtensions` types should be optional

Open PaulRBerg opened this issue 8 months ago • 0 comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • [x] I'm using the latest version of Docusaurus.
  • [x] I have tried the npm run clear or yarn clear command.
  • [x] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • [ ] I have tried creating a repro with https://new.docusaurus.io.
  • [ ] I have read the console error message carefully (if applicable).

Description

Defining the redirects separately (outside of the config object) produces a type error if the fromExtensions/ toExtensions fields are not defined.

Reproducible demo

No response

Steps to reproduce

Define the redirects like so:

import type { PluginOptions } from "@docusaurus/plugin-client-redirects";

// Will throw a type error
export const redirects: PluginOptions = {
  id: "default",
  // fromExtensions: [],
  // toExtensions: [],
  redirects: [
    // ...
  ]
}

Then, even if I uncomment those lines, I am still getting an error:

[Error [ValidationError]: "fromExtensions" does not contain 1 required value(s)]

Expected behavior

It should be possible to define the redirects without having to define fromExtensions and/ or toExtensions.

Actual behavior

Type error:

Type '{ id: string; redirects: { from: string; to: string; }[]; createRedirects(existingPath: string): any[]; }' is missing the following properties from type 'PluginOptions': fromExtensions, toExtensionsts(2739)

Your environment

  • Public source code: https://github.com/sablier-labs/docs
  • Public site URL: https://docs.sablier.com
  • Docusaurus version used: v3.7.0

Self-service

  • [ ] I'd be willing to fix this bug myself.

PaulRBerg avatar Apr 23 '25 10:04 PaulRBerg