diff --git a/index.d.ts b/index.d.ts index 4b97e1f9..a5bd661c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -89,8 +89,8 @@ export interface ParseOptions { readonly parseBooleans?: boolean; } -export interface ParsedQuery { - readonly [key: string]: string | number | boolean | Array | null | undefined; +export interface ParsedQuery { + [key: string]: T | T[] | null | undefined; } /** @@ -100,6 +100,9 @@ The returned object is created with [`Object.create(null)`](https://developer.mo @param query - The query string to parse. */ +export function parse(query: string, options: {parseBooleans: true, parseNumbers: true} & ParseOptions): ParsedQuery; +export function parse(query: string, options: {parseBooleans: true} & ParseOptions): ParsedQuery; +export function parse(query: string, options: {parseNumbers: true} & ParseOptions): ParsedQuery; export function parse(query: string, options?: ParseOptions): ParsedQuery; export interface ParsedUrl { diff --git a/index.test-d.ts b/index.test-d.ts index b3f9bb47..11e15c89 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -51,12 +51,15 @@ expectType( expectType( queryString.parse('?foo=bar', {arrayFormat: 'comma'}) ); -expectType( +expectType>( queryString.parse('?foo=1', {parseNumbers: true}) ); -expectType( +expectType>( queryString.parse('?foo=true', {parseBooleans: true}) ); +expectType>( + queryString.parse('?foo=true', {parseBooleans: true, parseNumbers: true}) +); // Parse URL expectType(queryString.parseUrl('?foo=bar'));