facebook / facebook/docusaurus

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

Đang mở
#9,654 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
66.2k
Fork
10k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
52

Mô tả

### 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.