diff --git a/types/treeify/index.d.ts b/types/treeify/index.d.ts new file mode 100644 index 0000000000..29375cf7ba --- /dev/null +++ b/types/treeify/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for tress 1.0 +// Project: https://github.com/notatestuser/treeify +// Definitions by: Mike North +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export interface TreeObject { + [k: string]: TreeValue; +} +export type TreeValue = string | TreeObject; + +export function asTree( + treeObj: TreeObject, + showValues: boolean, + hideFunctions: boolean +): string; + +export function asLines( + treeObj: TreeObject, + showValues: boolean, + lineCallback: (line: string) => void +): string; +export function asLines( + treeObj: TreeObject, + showValues: boolean, + hideFunctions: boolean, + lineCallback: (line: string) => void +): string; diff --git a/types/treeify/treeify-tests.ts b/types/treeify/treeify-tests.ts new file mode 100644 index 0000000000..b8132ec0cf --- /dev/null +++ b/types/treeify/treeify-tests.ts @@ -0,0 +1,35 @@ +import * as treeify from 'treeify'; + +function log(s: string): void {} + +treeify.asTree( + { + apples: 'gala', // ├─ apples: gala + oranges: 'mandarin' // └─ oranges: mandarin + }, + true, + true +); + +treeify.asLines( + { + apples: 'gala', // ├─ apples: gala + oranges: 'mandarin', // ├─ oranges: mandarin + grapes: { // └─ grapes + seedless: 'Thompson, Selma Pete', // ├─ seedless: Thompson, Selma Pete + seeded: 'concord' // └─ seeded: Concord + } + }, + true, + log +); + +treeify.asLines( + { + apples: 'gala', // ├─ apples: gala + oranges: 'mandarin' // └─ oranges: mandarin + }, + true, + false, + log +); diff --git a/types/treeify/tsconfig.json b/types/treeify/tsconfig.json new file mode 100644 index 0000000000..965d33c826 --- /dev/null +++ b/types/treeify/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [] + }, + "files": ["index.d.ts", "treeify-tests.ts"] +} diff --git a/types/treeify/tslint.json b/types/treeify/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/treeify/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +}