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

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

Closed
whitetrefoil opened this issue Jan 10, 2022 · 2 comments
Closed

Comments

@whitetrefoil
Copy link

whitetrefoil commented Jan 10, 2022

Bug report

In the bundled type delcaration file "types/lib/Server.d.ts", type ProxyConfigArray is defined to not an array but what its item should be.

Actual Behavior

type ProxyConfigArray = {
  path?: string | string[] | undefined;
  context?: string | string[] | HttpProxyMiddlewareOptionsFilter | undefined;
} & HttpProxyMiddlewareOptions &
  ByPass;

Expected Behavior

Below codes are modified base on @types/webpack-dev-server codes:

type ProxyConfigArrayItem = {
    path?: string | string[] | undefined;
    context?: string | string[] | HttpProxyMiddlewareOptionsFilter | undefined;
} & HttpProxyMiddlewareOptions &
  ByPass;

type ProxyConfigArray = ProxyConfigArrayItem[];

How Do We Reproduce?

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 : '',
    },
  ],
}

Please paste the results of npx webpack-cli info here, and mention other relevant information

Not using webpack-cli.
using webpack-dev-server@4.7.2
using typescript@4.5.4

@alexander-akait
Copy link
Member

PR welcome

@alexander-akait
Copy link
Member

Closed by #4173

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 a pull request may close this issue.

2 participants