facebook / facebook/docusaurus

Plugin API: Type definition of `configureWebpack` does allow all possible keys

Ouverte
#9,654 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
TypeScript
Étoiles
66.2k
Forks
10k
Merge moyen
1 j 3 h
PR mergées (30 j)
52

Description

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#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.
- [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).

### Description

The type definition for `configureWebpack` in the plugins API currently uses the `Configuration` type from webpack:
https://github.com/facebook/docusaurus/blob/affca7a9a28b2b07716336bc3103b0ff434169df/packages/docusaurus-types/src/plugin.d.ts#L125-L130

When I return an object containing a `devServer` key, this works as expected, but I get a type error because the `Configuration` type doesn't contain a key called `devServer`.

As far as I can tell, from some very uninformed searching, I think the type that this should actually be is https://github.com/webpack/webpack/blob/main/declarations/WebpackOptions.d.ts#L797.

### Reproducible demo

https://codesandbox.io/p/sandbox/docusaurus-webpack-devserver-tqk8nr

### Steps to reproduce

1. Open docusaurus.config.ts
2. Uncomment either of the keys under `plugins`
3. Observe the type error against `redirectPlugin`

### Expected behavior

I expect `docusaurus.config.ts` to type check successfully when `devServer` is configured

### Actual behavior

I get a type error in `docusaurus.config.ts` when `devServer` is configured, yet it definitely behaves as I expect

### Your environment

_No response_

### Self-service

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.