Merge pull request #32220 from BendingBender/all-keys

[all-keys] Add types
This commit is contained in:
Daniel Rosenwasser
2019-01-16 10:40:11 -08:00
committed by GitHub
4 changed files with 58 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
import allKeys = require('all-keys');
allKeys(Symbol.prototype); // $ExpectType Set<string>
allKeys(Symbol.prototype, { includeObjectPrototype: false }); // $ExpectType Set<string>
allKeys(Symbol.prototype, { includeSymbols: false }); // $ExpectType Set<string>
+29
View File
@@ -0,0 +1,29 @@
// Type definitions for all-keys 2.0
// Project: https://github.com/sindresorhus/all-keys#readme
// Definitions by: BendingBender <https://github.com/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<string>;
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;
}
}
+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",
"all-keys-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }