[whitelist-object] Add types

This commit is contained in:
Dimitri Benin
2018-12-16 14:15:46 +01:00
parent 39b514a4bb
commit 461cb6d758
4 changed files with 51 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for whitelist-object 1.0
// Project: https://github.com/conorhastings/whitelist-object#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = whitelistObject;
declare function whitelistObject(
object: { [key: string]: any },
keys: ReadonlyArray<string>,
shallow?: boolean
): { [key: string]: any };
+23
View File
@@ -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",
"whitelist-object-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,15 @@
import whiteListObject = require('whitelist-object');
const myObject = {
cool: 'guy',
conor: 'hastings',
wow: 'so cool',
but: { is: 'he', no: "he isn't" },
};
// $ExpectType { [key: string]: any; }
whiteListObject(myObject, ['cool', 'but', 'is']);
// $ExpectType { [key: string]: any; }
whiteListObject(myObject, ['cool', 'but', 'is'], false);
// $ExpectType { [key: string]: any; }
whiteListObject(myObject, ['cool', 'but', 'is'], true);