[simple-query-string]: Add v1 types (#39296)

This commit is contained in:
inglec-arista 2019-10-22 22:01:28 +01:00 committed by Wesley Wigham
parent 47c8ae5f36
commit f24547c4f9
4 changed files with 84 additions and 0 deletions

30
types/simple-query-string/index.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
// Type definitions for simple-query-string 1.3
// Project: https://github.com/khalidsalomao/simple-query-string#readme
// Definitions by: Ciarán Ingle <https://github.com/inglec-arista>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.6
declare const qs: {
version: string;
parse: (
str: string,
delimeter?: string,
eq?: string,
) => {
[key: string]: string | string[] | null;
};
stringify: <T>(
obj: {
/* tslint:disable-next-line ban-types */
[key: string]: T extends Function
? never
: T extends string | number | boolean | object | null ? T : never;
},
delimeter?: string,
eq?: string,
) => string;
};
export = qs;

View File

@ -0,0 +1,28 @@
import qs = require('simple-query-string');
// Omit optional parameters
qs.parse('http://example.org/test/?key=val&param=1');
// Omit last optional parameter
qs.parse('http://example.org/test/?key=val&param=1', '&');
// Specify all parameters
qs.parse('http://example.org/test/?key=val&param=1', '&', '=');
// Omit optional parameters
qs.stringify({});
qs.stringify({
param1: 'string',
param2: 123,
param3: true,
param4: ['element1', 'element2'],
param5: { key1: 'value1', key2: 'value2' },
param6: new RegExp('regex'),
param7: null,
});
// Omit last optional parameter
qs.stringify({}, '&');
// Specify all parameters
qs.stringify({}, '&', '=');

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"simple-query-string-tests.ts"
]
}

View File

@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}