mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Merge pull request #22491 from downace/types-caseless
[@types/caseless] Add type definition for caseless version 0.12
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import caseless, { Caseless, httpify } from "caseless";
|
||||
|
||||
new Caseless(); // $ExpectError
|
||||
|
||||
// tslint:disable-next-line: prefer-const
|
||||
let c1: Caseless;
|
||||
|
||||
caseless(); // $ExpectType Caseless
|
||||
caseless({}); // $ExpectType Caseless
|
||||
caseless(null); // $ExpectError
|
||||
caseless(1); // $ExpectError
|
||||
caseless("2"); // $ExpectError
|
||||
|
||||
const c2 = caseless();
|
||||
|
||||
c2.set({}); // $ExpectType void
|
||||
c2.set('foo', 'bar'); // $ExpectType string | false
|
||||
c2.set('foo', 'bar', false); // $ExpectType string | false
|
||||
c2.set('foo', new Date()); // $ExpectType string | false
|
||||
c2.set(10, 'bar'); // $ExpectError
|
||||
|
||||
c2.get('foo'); // $ExpectType any
|
||||
c2.get(10); // $ExpectError
|
||||
|
||||
c2.has('foo'); // $ExpectType string | false
|
||||
c2.has(10); // $ExpectError
|
||||
|
||||
c2.swap('foo'); // $ExpectType void
|
||||
c2.swap(10); // $ExpectError
|
||||
|
||||
c2.del('foo'); // $ExpectType boolean
|
||||
|
||||
httpify(null, {}); // $ExpectError
|
||||
httpify(1, {}); // $ExpectError
|
||||
httpify("2", {}); // $ExpectError
|
||||
httpify({}, null); // $ExpectError
|
||||
httpify({}, 1); // $ExpectError
|
||||
httpify({}, "2"); // $ExpectError
|
||||
|
||||
httpify({}, {}); // $ExpectType Caseless
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for caseless 0.12
|
||||
// Project: https://github.com/mikeal/caseless
|
||||
// Definitions by: downace <https://github.com/downace>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
type KeyType = string;
|
||||
type ValueType = any;
|
||||
type RawDict = object;
|
||||
|
||||
export interface Caseless {
|
||||
set(name: KeyType, value: ValueType, clobber?: boolean): KeyType | false;
|
||||
set(dict: RawDict): void;
|
||||
has(name: KeyType): KeyType | false;
|
||||
get(name: KeyType): ValueType | undefined;
|
||||
swap(name: KeyType): void;
|
||||
del(name: KeyType): boolean;
|
||||
}
|
||||
|
||||
export function httpify(resp: object, headers: RawDict): Caseless;
|
||||
|
||||
declare function caseless(dict?: RawDict): Caseless;
|
||||
|
||||
export default caseless;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"caseless-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user