From e1aee98aae953bded932132fddc3e2b5dda59818 Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Wed, 23 Oct 2019 19:29:50 +0900 Subject: [PATCH 1/7] Add initial typings. --- index.d.ts | 31 +++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..cc62131 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for unist-util-inspect +// Project: https://github.com/syntax-tree/unist-util-inspect/#readme +// TypeScript Version: 3.0 + +import * as Unist from 'unist'; + +export = inpect; + +/** + * Unist utility to inspect the details of a Unist Node + * + * @param node Node to inspect + */ +declare function inpect(node: Unist.Node): String; + +declare namespace inpect { + + /** + * Inspect the given Node and include colors from the results + * + * @param node Node to inspect + */ + function color(node: Unist.Node): String; + + /** + * Inspect the given Node and exclude colors from the results + * + * @param node Node to inspect + */ + function noColor(node: Unist.Node): String; +} diff --git a/package.json b/package.json index 1cc25fc..b2036a2 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,12 @@ "files": [ "index.js" ], + "types": "./index.d.ts", "dependencies": { "is-empty": "^1.0.0" }, "devDependencies": { + "@types/unist": "^2.0.3", "browserify": "^16.0.0", "chalk": "^2.3.0", "nyc": "^14.0.0", From 368ecbfca082e719565790c20b73fdff9768e0c7 Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Mon, 28 Oct 2019 18:17:50 +0900 Subject: [PATCH 2/7] Update types setup to match unist-builder --- index.d.ts | 31 ------------------------------- types/index.d.ts | 31 +++++++++++++++++++++++++++++++ types/tsconfig.json | 10 ++++++++++ types/tslint.json | 3 +++ types/unist-util-inspect-tests.ts | 30 ++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 31 deletions(-) delete mode 100644 index.d.ts create mode 100644 types/index.d.ts create mode 100644 types/tsconfig.json create mode 100644 types/tslint.json create mode 100644 types/unist-util-inspect-tests.ts diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cc62131..0000000 --- a/index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Type definitions for unist-util-inspect -// Project: https://github.com/syntax-tree/unist-util-inspect/#readme -// TypeScript Version: 3.0 - -import * as Unist from 'unist'; - -export = inpect; - -/** - * Unist utility to inspect the details of a Unist Node - * - * @param node Node to inspect - */ -declare function inpect(node: Unist.Node): String; - -declare namespace inpect { - - /** - * Inspect the given Node and include colors from the results - * - * @param node Node to inspect - */ - function color(node: Unist.Node): String; - - /** - * Inspect the given Node and exclude colors from the results - * - * @param node Node to inspect - */ - function noColor(node: Unist.Node): String; -} diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..58b2281 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for unist-util-inspect 4.1 +// Project: https://github.com/syntax-tree/unist-util-inspect/#readme +// Definitions by: Shane Handley +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 +import { Node } from 'unist'; + +export = inpect; + +/* + * Unist utility to inspect the details of a Unist Node + * + * @param node Node to inspect + */ +declare function inpect(node: Node): string; + +declare namespace inpect { + /** + * Inspect the given Node and include colors from the results + * + * @param node Node to inspect + */ + function color(node: Node): string; + + /** + * Inspect the given Node and exclude colors from the results + * + * @param node Node to inspect + */ + function noColor(node: Node): string; +} diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 0000000..7265426 --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "lib": ["es2015"], + "strict": true, + "baseUrl": ".", + "paths": { + "unist-util-inspect": ["index.d.ts"] + } + }, +} \ No newline at end of file diff --git a/types/tslint.json b/types/tslint.json new file mode 100644 index 0000000..30a1bdd --- /dev/null +++ b/types/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/unist-util-inspect-tests.ts b/types/unist-util-inspect-tests.ts new file mode 100644 index 0000000..355ed27 --- /dev/null +++ b/types/unist-util-inspect-tests.ts @@ -0,0 +1,30 @@ +import * as inspect from 'unist-util-inspect'; + +const node = { + type: 'node', + data: { + string: 'string', + number: 1, + object: { + key: 'value' + }, + array: [], + boolean: true, + null: null + }, + position: { + start: { + line: 1, + column: 1, + offset: 0 + }, + end: { + line: 1, + column: 4, + offset: 0 + }, + indent: [1] + } +}; + +const result: string = inspect(node); From 8ac93bc5ae51b04e3ecd97d15d5c734c182efe21 Mon Sep 17 00:00:00 2001 From: shanehandley <1322294+shanehandley@users.noreply.github.com> Date: Fri, 1 Nov 2019 14:34:45 +0900 Subject: [PATCH 3/7] Fix types reference Co-Authored-By: Christian Murphy --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b2036a2..286e9f1 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "files": [ "index.js" ], - "types": "./index.d.ts", + "types": "types/index.d.ts", "dependencies": { "is-empty": "^1.0.0" }, From 58e29bc0523224d774aeb483b347b0a00c5e437e Mon Sep 17 00:00:00 2001 From: shanehandley <1322294+shanehandley@users.noreply.github.com> Date: Fri, 1 Nov 2019 14:35:03 +0900 Subject: [PATCH 4/7] Add types to package.json Co-Authored-By: Christian Murphy --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 286e9f1..b470eb2 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "Titus Wormer (https://wooorm.com)" ], "files": [ - "index.js" + "index.js", + "types/index.d.ts" ], "types": "types/index.d.ts", "dependencies": { From ec31a99973bc2a967d4936593df814e1dc2e7d68 Mon Sep 17 00:00:00 2001 From: shanehandley <1322294+shanehandley@users.noreply.github.com> Date: Fri, 1 Nov 2019 14:35:30 +0900 Subject: [PATCH 5/7] JSON: dangling comma Co-Authored-By: Christian Murphy --- types/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/tsconfig.json b/types/tsconfig.json index 7265426..b04789a 100644 --- a/types/tsconfig.json +++ b/types/tsconfig.json @@ -6,5 +6,5 @@ "paths": { "unist-util-inspect": ["index.d.ts"] } - }, -} \ No newline at end of file + } +} From af5fa9433e987806418a698a5a0c36ea1b159da9 Mon Sep 17 00:00:00 2001 From: shanehandley <1322294+shanehandley@users.noreply.github.com> Date: Fri, 1 Nov 2019 14:35:57 +0900 Subject: [PATCH 6/7] Fix dtslint reference Co-Authored-By: Christian Murphy --- types/tslint.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/tslint.json b/types/tslint.json index 30a1bdd..6490e53 100644 --- a/types/tslint.json +++ b/types/tslint.json @@ -1,3 +1,3 @@ { - "extends": "dtslint/dt.json" -} \ No newline at end of file + "extends": "dtslint/dtslint.json" +} From 43fe76737f3ee851d9d23e7d2c4d50339cadda8d Mon Sep 17 00:00:00 2001 From: Shane Handley Date: Fri, 1 Nov 2019 14:41:57 +0900 Subject: [PATCH 7/7] Add dtslint, remove noise from typings that was required for DefinitelyTyped validation. --- package.json | 4 +++- types/index.d.ts | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b470eb2..fb77ed8 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@types/unist": "^2.0.3", "browserify": "^16.0.0", "chalk": "^2.3.0", + "dtslint": "^1.0.2", "nyc": "^14.0.0", "prettier": "^1.0.0", "remark-cli": "^6.0.0", @@ -44,7 +45,8 @@ "build": "npm run build-bundle && npm run build-mangle", "test-api": "node test", "test-coverage": "nyc --reporter lcov tape test.js", - "test": "npm run format && npm run build && npm run test-coverage" + "test": "npm run format && npm run build && npm run test-coverage", + "dtslint": "dtslint types" }, "prettier": { "tabWidth": 2, diff --git a/types/index.d.ts b/types/index.d.ts index 58b2281..b7f2d5d 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,7 +1,3 @@ -// Type definitions for unist-util-inspect 4.1 -// Project: https://github.com/syntax-tree/unist-util-inspect/#readme -// Definitions by: Shane Handley -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 import { Node } from 'unist';