[express-server-static-core] Allow mixed arrays in query params (#43823)

The express default query parser (qs.parse) can return an array that mixes strings and objects. This commit changes the typing of `Query` to represent that case.

Example of a case now covered that was previously not represented by the type:

```
> const qs = require('qs')
> qs.parse('a=string&a[key]=value')
{ a: [ 'string', { key: 'value' } ] }
```
This commit is contained in:
Tilman Stehr 2020-04-15 05:27:09 +02:00 committed by GitHub
parent 888fbc130e
commit db069750c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,7 @@ export type ParamsArray = string[];
export type Params = ParamsDictionary | ParamsArray;
// Return type of qs.parse, the default query parser (https://expressjs.com/en/api.html#app-settings-property).
export interface Query { [key: string]: string | string[] | Query | Query[]; }
export interface Query { [key: string]: string | Query | Array<string | Query>; }
export interface RequestHandler<P extends Params = ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = Query> {
// tslint:disable-next-line callable-types (This is extended from and can't extend from a type alias in ts<2.2