Skip to content

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

@whitetrefoil

Description

@whitetrefoil

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions