From 63c0b20f2c5fe3de216d4d41c0f6cccee21f0246 Mon Sep 17 00:00:00 2001 From: Charles Samborski Date: Sat, 11 Nov 2017 23:39:41 +0100 Subject: [PATCH] Add types for `object-inspect@1.4` This commit add type declarations for `object-inspect`. Related: - https://github.com/substack/object-inspect/pull/17 --- types/object-inspect/index.d.ts | 27 ++++++++++++++++++++ types/object-inspect/object-inspect-tests.ts | 10 ++++++++ types/object-inspect/tsconfig.json | 23 +++++++++++++++++ types/object-inspect/tslint.json | 1 + 4 files changed, 61 insertions(+) create mode 100644 types/object-inspect/index.d.ts create mode 100644 types/object-inspect/object-inspect-tests.ts create mode 100644 types/object-inspect/tsconfig.json create mode 100644 types/object-inspect/tslint.json diff --git a/types/object-inspect/index.d.ts b/types/object-inspect/index.d.ts new file mode 100644 index 0000000000..ed72d3266a --- /dev/null +++ b/types/object-inspect/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for object-inspect 1.4 +// Project: https://github.com/substack/object-inspect +// Definitions by: Charles Samborski +// 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; diff --git a/types/object-inspect/object-inspect-tests.ts b/types/object-inspect/object-inspect-tests.ts new file mode 100644 index 0000000000..22a1e4ab56 --- /dev/null +++ b/types/object-inspect/object-inspect-tests.ts @@ -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}); diff --git a/types/object-inspect/tsconfig.json b/types/object-inspect/tsconfig.json new file mode 100644 index 0000000000..1f167ba039 --- /dev/null +++ b/types/object-inspect/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", + "object-inspect-tests.ts" + ] +} diff --git a/types/object-inspect/tslint.json b/types/object-inspect/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/object-inspect/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }