New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ProxyConfigArray
in type def is not an Array
#4163
Conversation
|
Codecov Report
@@ Coverage Diff @@
## master #4163 +/- ##
==========================================
+ Coverage 92.15% 92.28% +0.12%
==========================================
Files 14 14
Lines 1543 1543
Branches 590 590
==========================================
+ Hits 1422 1424 +2
+ Misses 112 110 -2
Partials 9 9
Continue to review full report at Codecov.
|
@@ -121,11 +121,15 @@ const schema = require("./options.json"); | |||
* @callback ByPass | |||
* @param {Request} req | |||
* @param {Response} res | |||
* @param {ProxyConfigArray} proxyConfig | |||
* @param {ProxyConfigArrayItem} proxyConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something wrong here ByPass
can't have ByPass
inside
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't actually run the code yet, but looked at line 2222 it seemed to just pass the whole proxyConfig
as-is:
const isByPassFuncDefined =
typeof proxyConfig.bypass === "function";
const bypassUrl = isByPassFuncDefined
? await proxyConfig.bypass(req, res, proxyConfig)
: null;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide configuration where we have a problem with types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure~ I've put a minimial repro. in the original issue #4161, but I made a mistake during cleanup codes, fixed now:
import type { Configuration } from 'webpack-dev-server'
const apiPrefixes: string[] = ['/api/']
const devServerOptions: Configuration = {
proxy: [
{
// TS2322: Type '{ context: string[]; target: string; }' is not assignable to type 'Options'.
// Object literal may only specify known properties, and 'context' does not exist in type 'Options'.
context: apiPrefixes,
target : '',
},
],
}
That code works when using the old @types/webpack-dev-server
, but throws TS error when using webpack-dev-server
's new bundle types. (And it actually works if I just ignores the TS type error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have more errors - try #4173
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4173 works for my case, should I close this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, let's close, merged #4173, anyway thanks for PR
For Bugs and Features; did you add new tests?
No, it's a pure type declaration fix, no actual code.
Motivation / Use-Case
Fixes #4161
Breaking Changes
No breaking change.
Additional Info