From d7ee161569535bbac6ba3cb2af3dc59633f459e4 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 20 Feb 2018 20:23:41 +0100 Subject: [PATCH 1/4] New typings for csv2json --- types/csv2json/csv2json-tests.ts | 8 ++++++++ types/csv2json/index.d.ts | 15 +++++++++++++++ types/csv2json/tsconfig.json | 23 +++++++++++++++++++++++ types/csv2json/tslint.json | 1 + 4 files changed, 47 insertions(+) create mode 100644 types/csv2json/csv2json-tests.ts create mode 100644 types/csv2json/index.d.ts create mode 100644 types/csv2json/tsconfig.json create mode 100644 types/csv2json/tslint.json diff --git a/types/csv2json/csv2json-tests.ts b/types/csv2json/csv2json-tests.ts new file mode 100644 index 0000000000..269d4c2dfe --- /dev/null +++ b/types/csv2json/csv2json-tests.ts @@ -0,0 +1,8 @@ +import csv2json from "csv2json"; +import fs from "fs"; + +fs.createReadStream('data.csv') + .pipe(csv2json({ + separator: ';' + })) + .pipe(fs.createWriteStream('data.json')); diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts new file mode 100644 index 0000000000..f1c08c3e7c --- /dev/null +++ b/types/csv2json/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for csv2json 1.4 +// Project: https://github.com/julien-f/csv2json +// Definitions by: Piotr Roszatycki +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Writable } from "stream"; + +export interface CSV2JSONOptions { + dynamicTyping?: boolean; + separator?: string; +} + +export default function csv2json (options: CSV2JSONOptions): Writable; diff --git a/types/csv2json/tsconfig.json b/types/csv2json/tsconfig.json new file mode 100644 index 0000000000..e9840faef7 --- /dev/null +++ b/types/csv2json/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "csv2json-tests.ts" + ] +} diff --git a/types/csv2json/tslint.json b/types/csv2json/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/csv2json/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 20be1b2329f13c8b8f8a42d07cad308a999e27d8 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 20 Feb 2018 20:43:12 +0100 Subject: [PATCH 2/4] linter clean --- types/csv2json/index.d.ts | 3 ++- types/csv2json/tsconfig.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts index f1c08c3e7c..1ea9d5c6eb 100644 --- a/types/csv2json/index.d.ts +++ b/types/csv2json/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/julien-f/csv2json // Definitions by: Piotr Roszatycki // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.7 /// @@ -12,4 +13,4 @@ export interface CSV2JSONOptions { separator?: string; } -export default function csv2json (options: CSV2JSONOptions): Writable; +export default function csv2json(options: CSV2JSONOptions): Writable; diff --git a/types/csv2json/tsconfig.json b/types/csv2json/tsconfig.json index e9840faef7..79a635ca7d 100644 --- a/types/csv2json/tsconfig.json +++ b/types/csv2json/tsconfig.json @@ -6,6 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, + "strictFunctionTypes": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ From f602a6db7619a426bd9e814b38a9439c4fb44f31 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 20 Feb 2018 21:12:37 +0100 Subject: [PATCH 3/4] This typings is for TypeScript 2.7 only but Microsoft/definitelytyped-header-parser#11 is not fixed --- types/csv2json/csv2json-tests.ts | 2 +- types/csv2json/index.d.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/csv2json/csv2json-tests.ts b/types/csv2json/csv2json-tests.ts index 269d4c2dfe..9e4e6cbdd3 100644 --- a/types/csv2json/csv2json-tests.ts +++ b/types/csv2json/csv2json-tests.ts @@ -1,5 +1,5 @@ import csv2json from "csv2json"; -import fs from "fs"; +import fs = require("fs"); fs.createReadStream('data.csv') .pipe(csv2json({ diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts index 1ea9d5c6eb..713f4a05bc 100644 --- a/types/csv2json/index.d.ts +++ b/types/csv2json/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/julien-f/csv2json // Definitions by: Piotr Roszatycki // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.7 /// From 9ad2aeb4fb983595d6e8c2538ef187c7349fd328 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Mon, 5 Mar 2018 10:29:28 +0100 Subject: [PATCH 4/4] Compatibility with TypeScript < 2.7 --- types/csv2json/csv2json-tests.ts | 2 +- types/csv2json/index.d.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/csv2json/csv2json-tests.ts b/types/csv2json/csv2json-tests.ts index 9e4e6cbdd3..b211fd9aee 100644 --- a/types/csv2json/csv2json-tests.ts +++ b/types/csv2json/csv2json-tests.ts @@ -1,4 +1,4 @@ -import csv2json from "csv2json"; +import csv2json = require("csv2json"); import fs = require("fs"); fs.createReadStream('data.csv') diff --git a/types/csv2json/index.d.ts b/types/csv2json/index.d.ts index 713f4a05bc..6906d3e925 100644 --- a/types/csv2json/index.d.ts +++ b/types/csv2json/index.d.ts @@ -7,9 +7,13 @@ import { Writable } from "stream"; -export interface CSV2JSONOptions { - dynamicTyping?: boolean; - separator?: string; +declare namespace csv2json { + interface Options { + dynamicTyping?: boolean; + separator?: string; + } } -export default function csv2json(options: CSV2JSONOptions): Writable; +declare function csv2json(options?: csv2json.Options): Writable; + +export = csv2json;