From 23d567d796c0862f36c11a971083abc7590a1f0a Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Wed, 16 Jan 2019 19:02:21 +0100 Subject: [PATCH] [all-keys] Add types --- types/all-keys/all-keys-tests.ts | 5 +++++ types/all-keys/index.d.ts | 29 +++++++++++++++++++++++++++++ types/all-keys/tsconfig.json | 23 +++++++++++++++++++++++ types/all-keys/tslint.json | 1 + 4 files changed, 58 insertions(+) create mode 100644 types/all-keys/all-keys-tests.ts create mode 100644 types/all-keys/index.d.ts create mode 100644 types/all-keys/tsconfig.json create mode 100644 types/all-keys/tslint.json diff --git a/types/all-keys/all-keys-tests.ts b/types/all-keys/all-keys-tests.ts new file mode 100644 index 0000000000..6bbb6021c7 --- /dev/null +++ b/types/all-keys/all-keys-tests.ts @@ -0,0 +1,5 @@ +import allKeys = require('all-keys'); + +allKeys(Symbol.prototype); // $ExpectType Set +allKeys(Symbol.prototype, { includeObjectPrototype: false }); // $ExpectType Set +allKeys(Symbol.prototype, { includeSymbols: false }); // $ExpectType Set diff --git a/types/all-keys/index.d.ts b/types/all-keys/index.d.ts new file mode 100644 index 0000000000..9301c8f929 --- /dev/null +++ b/types/all-keys/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for all-keys 2.0 +// Project: https://github.com/sindresorhus/all-keys#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export = allKeys; + +/** + * Get all property keys of an object including non-enumerable and inherited ones. + * Like [Reflect.ownKeys()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys) + * but traverses up the prototype-chain. + */ +declare function allKeys(obj: object, options?: allKeys.Options): Set; + +declare namespace allKeys { + interface Options { + /** + * Include `Object.prototype` properties like `isPrototypeOf`. + * @default true + */ + includeObjectPrototype?: boolean; + /** + * Include [Symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) keys. + * @default true + */ + includeSymbols?: boolean; + } +} diff --git a/types/all-keys/tsconfig.json b/types/all-keys/tsconfig.json new file mode 100644 index 0000000000..a6f20f786f --- /dev/null +++ b/types/all-keys/tsconfig.json @@ -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", + "all-keys-tests.ts" + ] +} diff --git a/types/all-keys/tslint.json b/types/all-keys/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/all-keys/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }