mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[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:
parent
888fbc130e
commit
db069750c2
2
types/express-serve-static-core/index.d.ts
vendored
2
types/express-serve-static-core/index.d.ts
vendored
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user