Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

whitetrefoil
Copy link

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

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

@linux-foundation-easycla
Copy link

CLA Not Signed

@codecov
Copy link

codecov bot commented Jan 11, 2022

Codecov Report

Merging #4163 (8a56621) into master (75999bb) will increase coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
lib/Server.js 93.73% <ø> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75999bb...8a56621. Read the comment docs.

@@ -121,11 +121,15 @@ const schema = require("./options.json");
* @callback ByPass
* @param {Request} req
* @param {Response} res
* @param {ProxyConfigArray} proxyConfig
* @param {ProxyConfigArrayItem} proxyConfig
Copy link
Member

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

Copy link
Author

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;

Copy link
Member

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?

Copy link
Author

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)

Copy link
Member

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

Copy link
Author

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?

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProxyConfigArray in type def (types/lib/Server.d.ts) is not an Array
2 participants