mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[simple-query-string]: Add v1 types (#39296)
This commit is contained in:
parent
47c8ae5f36
commit
f24547c4f9
30
types/simple-query-string/index.d.ts
vendored
Normal file
30
types/simple-query-string/index.d.ts
vendored
Normal 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;
|
||||
28
types/simple-query-string/simple-query-string-tests.ts
Normal file
28
types/simple-query-string/simple-query-string-tests.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import qs = require('simple-query-string');
|
||||
|
||||
// Omit optional parameters
|
||||
qs.parse('http://example.org/test/?key=val¶m=1');
|
||||
|
||||
// Omit last optional parameter
|
||||
qs.parse('http://example.org/test/?key=val¶m=1', '&');
|
||||
|
||||
// Specify all parameters
|
||||
qs.parse('http://example.org/test/?key=val¶m=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({}, '&', '=');
|
||||
23
types/simple-query-string/tsconfig.json
Normal file
23
types/simple-query-string/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
3
types/simple-query-string/tslint.json
Normal file
3
types/simple-query-string/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user