🤖 Merge PR #59350 [console-log-tree] Added definitions by @ChocolateLoverRaj

* [console-log-tree] Added definitions

* Remove extra space in `types/console-log-tree/index.d.ts`

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>

* Add optional params to `parse`

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
This commit is contained in:
Rajas Paranjpe
2022-03-28 17:04:01 -07:00
committed by GitHub
parent 59a8ffb15c
commit 71a3388f05
4 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import logTree = require('console-log-tree');
// $ExpectType string
const treeString = logTree.parse([{
name: 'Planets',
children: [{
name: 'Earth',
children: [{
name: 'Moon'
}]
}, {
name: 'Venus'
}]
}, {
name: 'Empty Tree'
}]);
// $ExpectType void
logTree.log({
name: 'My Tree'
});
// $ExpectError
logTree.log({});
// $ExpectError
logTree({ name: 'Hello' });

14
types/console-log-tree/index.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
// Type definitions for console-log-tree 1.2
// Project: https://github.com/QiShaoXuan/log-tree#readme
// Definitions by: Rajas Paranjpe <https://github.com/ChocolateLoverRaj>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace library;
export interface Tree {
name: string;
children?: readonly Tree[];
}
export function parse(tree: Tree | readonly Tree[], parentPre?: string, treeStr?: string): string;
export function log(tree: Tree | readonly Tree[]): void;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"console-log-tree-tests.ts"
]
}

View File

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