Add types for object-inspect@1.4

This commit add type declarations for `object-inspect`.

Related:
- https://github.com/substack/object-inspect/pull/17
This commit is contained in:
Charles Samborski 2017-11-11 23:39:41 +01:00
parent 1a051f0000
commit 63c0b20f2c
No known key found for this signature in database
GPG Key ID: 772D60E3C9984A85
4 changed files with 61 additions and 0 deletions

27
types/object-inspect/index.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
// Type definitions for object-inspect 1.4
// Project: https://github.com/substack/object-inspect
// Definitions by: Charles Samborski <https://github.com/demurgos>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace objectInspect {
/**
* Inspection options
*/
interface Options {
/**
* Maximum depth of the inspection. Default: `5`.
*/
depth?: number;
}
}
/**
* Return a string `s` with the string representation of `obj` up to a depth of `opts.depth`.
*
* @param obj Object to inspect
* @param opts Inspection options. Default: `{}`.
* @return String representation of `obj`
*/
declare function objectInspect(obj: any, opts?: objectInspect.Options): string;
export = objectInspect;

View File

@ -0,0 +1,10 @@
import objectInspect = require('object-inspect');
// $ExpectType string
objectInspect({foo: "bar"});
// $ExpectType string
objectInspect({foo: "bar"}, {});
// $ExpectType string
objectInspect({foo: "bar"}, {depth: Infinity});

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",
"object-inspect-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }