From a9f28043d36f233f7aab3eb120fb7744c561d6cf Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 20 Aug 2018 15:54:38 -0400 Subject: [PATCH 01/21] Add Typescript Definition --- index.d.ts | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 1 + package.json | 4 +++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..56925f8 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,53 @@ +interface Options { + /** + * Applies a function to the JSON string before parsing. + */ + beforeParse?: Function + /** + * Prescribes how the value originally produced by parsing is transformed, before being returned. + * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. + */ + reviver?: Function +} + +/** + * Read and parse a JSON file + * + * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. + * + * @param {string} filepath Filepath + * @param {any} data Data + * @param {object} [options] Optional parameters + * @param {function} [options.beforeParse] Applies a function to the JSON string before parsing. + * @param {function} [options.reviver] Prescribes how the value originally produced by parsing is transformed, before being returned. + * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. + * @returns {void} + * @example + * const loadJsonFile = require('load-json-file'); + * + * loadJsonFile.sync('foo.json') + * console.log(json); + */ +export function sync(filepath: string, options?: Options): void; + +/** + * Read and parse a JSON file + * + * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. + * + * @param {string} filepath Filepath + * @param {any} data Data + * @param {object} [options] Optional parameters + * @param {function} [options.beforeParse] Applies a function to the JSON string before parsing. + * @param {function} [options.reviver] Prescribes how the value originally produced by parsing is transformed, before being returned. + * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. + * @returns {Promise} + * @example + * const loadJsonFile = require('load-json-file'); + * + * loadJsonFile('foo.json').then(json => { + * console.log(json); + * //=> {foo: true} + * }); + */ +export default function loadJsonFile(filepath: string, options?: Options): Promise; diff --git a/index.js b/index.js index 7828e2a..abf06af 100644 --- a/index.js +++ b/index.js @@ -16,4 +16,5 @@ const parse = (data, filePath, options = {}) => { }; module.exports = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options)); +module.exports.default = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options)); module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options); diff --git a/package.json b/package.json index 292f1b3..912a877 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,10 @@ "test": "xo && ava" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], + "types": "index.d.ts", "keywords": [ "read", "json", From c8ae0857f6b989227eaf4eea9d9543025126a9be Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 20 Aug 2018 16:10:24 -0400 Subject: [PATCH 02/21] Update based on comments --- index.js | 6 ++++-- package.json | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index abf06af..1406c41 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,8 @@ const parse = (data, filePath, options = {}) => { return parseJson(data, options.reviver, path.relative(process.cwd(), filePath)); }; -module.exports = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options)); -module.exports.default = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options)); +const loadJsonFile = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options)); + +module.export = loadJsonFile; +module.exports.default = loadJsonFile; module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options); diff --git a/package.json b/package.json index 912a877..a60524f 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "index.js", "index.d.ts" ], - "types": "index.d.ts", "keywords": [ "read", "json", From 302aa2a209ef968e0227d8dd0f9228d878d1dcfb Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 20 Aug 2018 16:32:05 -0400 Subject: [PATCH 03/21] Update based on comments --- index.d.ts | 24 ++++++------------------ package.json | 2 +- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/index.d.ts b/index.d.ts index 56925f8..340b443 100644 --- a/index.d.ts +++ b/index.d.ts @@ -15,15 +15,9 @@ interface Options { * * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * - * @param {string} filepath Filepath - * @param {any} data Data - * @param {object} [options] Optional parameters - * @param {function} [options.beforeParse] Applies a function to the JSON string before parsing. - * @param {function} [options.reviver] Prescribes how the value originally produced by parsing is transformed, before being returned. - * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. * @returns {void} * @example - * const loadJsonFile = require('load-json-file'); + * import * as loadJsonFile from 'load-json-file'; * * loadJsonFile.sync('foo.json') * console.log(json); @@ -35,19 +29,13 @@ export function sync(filepath: string, options?: Options): void; * * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * - * @param {string} filepath Filepath - * @param {any} data Data - * @param {object} [options] Optional parameters - * @param {function} [options.beforeParse] Applies a function to the JSON string before parsing. - * @param {function} [options.reviver] Prescribes how the value originally produced by parsing is transformed, before being returned. - * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. * @returns {Promise} * @example - * const loadJsonFile = require('load-json-file'); + * import loadJsonFile 'load-json-file'; * - * loadJsonFile('foo.json').then(json => { - * console.log(json); - * //=> {foo: true} - * }); + * (async () => { + * await loadJsonFile('foo.json'); + * console.log('done'); + * })(); */ export default function loadJsonFile(filepath: string, options?: Options): Promise; diff --git a/package.json b/package.json index a60524f..fec1fc0 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=6" }, "scripts": { - "test": "xo && ava" + "test": "xo --ignore index.d.ts && ava" }, "files": [ "index.js", From f3b32c034b5fcd2a882e6fe452252d6ab9abad1e Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 20 Aug 2018 16:33:30 -0400 Subject: [PATCH 04/21] Add dot & ignore xo --- index.d.ts | 4 ++-- package.json | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 340b443..7fac7ab 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,7 +11,7 @@ interface Options { } /** - * Read and parse a JSON file + * Read and parse a JSON file. * * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * @@ -25,7 +25,7 @@ interface Options { export function sync(filepath: string, options?: Options): void; /** - * Read and parse a JSON file + * Read and parse a JSON file. * * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * diff --git a/package.json b/package.json index fec1fc0..10875c5 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=6" }, "scripts": { - "test": "xo --ignore index.d.ts && ava" + "test": "xo && ava" }, "files": [ "index.js", @@ -37,5 +37,10 @@ "devDependencies": { "ava": "*", "xo": "*" + }, + "xo": { + "ignores": [ + "index.d.ts" + ] } } From 2bbbe344e8010ad5c37194c6703c637a85b0a84a Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 20 Aug 2018 16:45:57 -0400 Subject: [PATCH 05/21] Remove {void} & fix indentation --- index.d.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index 7fac7ab..b2d9154 100644 --- a/index.d.ts +++ b/index.d.ts @@ -15,7 +15,6 @@ interface Options { * * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * - * @returns {void} * @example * import * as loadJsonFile from 'load-json-file'; * @@ -29,13 +28,12 @@ export function sync(filepath: string, options?: Options): void; * * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * - * @returns {Promise} * @example - * import loadJsonFile 'load-json-file'; + * import loadJsonFile from 'load-json-file'; * * (async () => { - * await loadJsonFile('foo.json'); - * console.log('done'); + * await loadJsonFile('foo.json'); + * console.log('done'); * })(); */ export default function loadJsonFile(filepath: string, options?: Options): Promise; From 129e0583955322e4b34b3c254c584cbe78eb35bc Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 20 Aug 2018 16:53:09 -0400 Subject: [PATCH 06/21] Fix example --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index b2d9154..6171068 100644 --- a/index.d.ts +++ b/index.d.ts @@ -16,7 +16,7 @@ interface Options { * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * * @example - * import * as loadJsonFile from 'load-json-file'; + * import loadJsonFile from 'load-json-file'; * * loadJsonFile.sync('foo.json') * console.log(json); From 017faadaab680096dff10b8876a4b292a29e6c4e Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Mon, 20 Aug 2018 17:04:04 -0400 Subject: [PATCH 07/21] Change module.export => module.exports --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 1406c41..0b9a86b 100644 --- a/index.js +++ b/index.js @@ -17,6 +17,6 @@ const parse = (data, filePath, options = {}) => { const loadJsonFile = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options)); -module.export = loadJsonFile; +module.exports = loadJsonFile; module.exports.default = loadJsonFile; module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options); From a3f21f9c9e85227196c0530225ebdbd53c97917b Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Tue, 21 Aug 2018 00:56:17 -0400 Subject: [PATCH 08/21] Fix import --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 6171068..b2d9154 100644 --- a/index.d.ts +++ b/index.d.ts @@ -16,7 +16,7 @@ interface Options { * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * * @example - * import loadJsonFile from 'load-json-file'; + * import * as loadJsonFile from 'load-json-file'; * * loadJsonFile.sync('foo.json') * console.log(json); From d3dad7ba8131f99a2cae7a0494e9414f953306f1 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Tue, 21 Aug 2018 13:20:47 -0400 Subject: [PATCH 09/21] Update @example & include generic T=any --- index.d.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index b2d9154..043d944 100644 --- a/index.d.ts +++ b/index.d.ts @@ -18,10 +18,11 @@ interface Options { * @example * import * as loadJsonFile from 'load-json-file'; * - * loadJsonFile.sync('foo.json') + * const json = loadJsonFile.sync('foo.json') * console.log(json); + * //=> {foo: true} */ -export function sync(filepath: string, options?: Options): void; +export function sync(filepath: string, options?: Options): T; /** * Read and parse a JSON file. @@ -32,8 +33,9 @@ export function sync(filepath: string, options?: Options): void; * import loadJsonFile from 'load-json-file'; * * (async () => { - * await loadJsonFile('foo.json'); - * console.log('done'); + * const json = await loadJsonFile('foo.json'); + * console.log(json); + * //=> {foo: true} * })(); */ -export default function loadJsonFile(filepath: string, options?: Options): Promise; +export default function loadJsonFile(filepath: string, options?: Options): Promise; From 26c0380323716ba5143415c812633247a17c6725 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Tue, 21 Aug 2018 14:40:28 -0400 Subject: [PATCH 10/21] Expand Function details --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 043d944..9434be6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,13 +1,13 @@ -interface Options { +export interface Options { /** * Applies a function to the JSON string before parsing. */ - beforeParse?: Function + beforeParse?: (data: string) => string; /** * Prescribes how the value originally produced by parsing is transformed, before being returned. * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. */ - reviver?: Function + reviver?: (key: string, value: any) => any; } /** From 2584c36fb36f36c0069bb819060791343f6bacc9 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Tue, 21 Aug 2018 14:42:39 -0400 Subject: [PATCH 11/21] Export optional types --- index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9434be6..b8ff1b7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,13 +1,16 @@ +export type Reviver = (key: string, value: any) => any; +export type BeforeParse = (data: string) => string; + export interface Options { /** * Applies a function to the JSON string before parsing. */ - beforeParse?: (data: string) => string; + beforeParse?: BeforeParse; /** * Prescribes how the value originally produced by parsing is transformed, before being returned. * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. */ - reviver?: (key: string, value: any) => any; + reviver?: Reviver; } /** From 8b792d69f97d2d463d82f212d11fe16551b44955 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 27 Aug 2018 15:42:33 +0700 Subject: [PATCH 12/21] Update index.d.ts --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index b8ff1b7..495f4ad 100644 --- a/index.d.ts +++ b/index.d.ts @@ -8,7 +8,7 @@ export interface Options { beforeParse?: BeforeParse; /** * Prescribes how the value originally produced by parsing is transformed, before being returned. - * See the [JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. + * See the [`JSON.parse` docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter) for more. */ reviver?: Reviver; } From bbe8b247d0edf0d9bebb91b8a3d1a199dcbe02bd Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Wed, 29 Aug 2018 15:19:17 -0400 Subject: [PATCH 13/21] Update changes @sindresorhus --- index.d.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index b8ff1b7..2c334a1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -21,11 +21,10 @@ export interface Options { * @example * import * as loadJsonFile from 'load-json-file'; * - * const json = loadJsonFile.sync('foo.json') - * console.log(json); + * const json = loadJsonFile.sync('foo.json'); * //=> {foo: true} */ -export function sync(filepath: string, options?: Options): T; +export function sync(filePath: string, options?: Options): T; /** * Read and parse a JSON file. @@ -37,8 +36,7 @@ export function sync(filepath: string, options?: Options): T; * * (async () => { * const json = await loadJsonFile('foo.json'); - * console.log(json); * //=> {foo: true} * })(); */ -export default function loadJsonFile(filepath: string, options?: Options): Promise; +export default function loadJsonFile(filePath: string, options?: Options): Promise; From d2bd1d78bc448fe88cae9fa25a089c4cd38a6a9a Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Wed, 29 Aug 2018 15:25:03 -0400 Subject: [PATCH 14/21] Add extra return after @example --- index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.d.ts b/index.d.ts index 098b99a..1a42388 100644 --- a/index.d.ts +++ b/index.d.ts @@ -19,6 +19,7 @@ export interface Options { * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * * @example + * * import * as loadJsonFile from 'load-json-file'; * * const json = loadJsonFile.sync('foo.json'); @@ -32,6 +33,7 @@ export function sync(filePath: string, options?: Options): T; * Strips UTF-8 BOM, uses graceful-fs, and throws more helpful JSON errors. * * @example + * * import loadJsonFile from 'load-json-file'; * * (async () => { From c95f14fbefb6c9b566836765f65cc76f6f61a23b Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 6 Sep 2018 00:06:29 -0600 Subject: [PATCH 15/21] Add index.test-d.ts --- index.test-d.ts | 16 ++++++++++++++++ package.json | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 index.test-d.ts diff --git a/index.test-d.ts b/index.test-d.ts new file mode 100644 index 0000000..52e92e0 --- /dev/null +++ b/index.test-d.ts @@ -0,0 +1,16 @@ +import {expectType} from 'tsd-check'; +import loadJsonFile, {sync, Reviver, BeforeParse} from '.'; + +(async () => { + // To-Do => Expand Tests + // https://github.com/sindresorhus/write-json-file/blob/master/index.test-d.ts + expectType(() => 1); + expectType((a: string) => a.length); + expectType((a: string, b: string) => a.length - b.length); + + expectType((data) => data); + + expectType(await loadJsonFile('unicorn.json')); + + expectType(sync('unicorn.json')); +})(); \ No newline at end of file diff --git a/package.json b/package.json index 10875c5..8461f6a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=6" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd-check" }, "files": [ "index.js", @@ -36,6 +36,7 @@ }, "devDependencies": { "ava": "*", + "tsd-check": "^0.1.0", "xo": "*" }, "xo": { From e198adb97dfba666826120e0db974bef61271642 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 7 Sep 2018 16:15:45 +0700 Subject: [PATCH 16/21] Update package.json --- package.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/package.json b/package.json index 8461f6a..2b64742 100644 --- a/package.json +++ b/package.json @@ -38,10 +38,5 @@ "ava": "*", "tsd-check": "^0.1.0", "xo": "*" - }, - "xo": { - "ignores": [ - "index.d.ts" - ] } } From 9c96144dd554f72764b07f36f0b0fbb87f0b226c Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 7 Sep 2018 11:06:28 -0600 Subject: [PATCH 17/21] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b64742..f6cc5e7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "ava": "*", - "tsd-check": "^0.1.0", + "tsd-check": "*", "xo": "*" } } From 2a11d5d180b1abebbb9c6c42730fa2298571ee3b Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 7 Sep 2018 11:33:53 -0600 Subject: [PATCH 18/21] Change any to unknown --- index.d.ts | 4 ++-- index.test-d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 1a42388..6b4f027 100644 --- a/index.d.ts +++ b/index.d.ts @@ -25,7 +25,7 @@ export interface Options { * const json = loadJsonFile.sync('foo.json'); * //=> {foo: true} */ -export function sync(filePath: string, options?: Options): T; +export function sync(filePath: string, options?: Options): T; /** * Read and parse a JSON file. @@ -41,4 +41,4 @@ export function sync(filePath: string, options?: Options): T; * //=> {foo: true} * })(); */ -export default function loadJsonFile(filePath: string, options?: Options): Promise; +export default function loadJsonFile(filePath: string, options?: Options): Promise; diff --git a/index.test-d.ts b/index.test-d.ts index 52e92e0..a9fb8b2 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -10,7 +10,7 @@ import loadJsonFile, {sync, Reviver, BeforeParse} from '.'; expectType((data) => data); - expectType(await loadJsonFile('unicorn.json')); + expectType(await loadJsonFile('unicorn.json')); - expectType(sync('unicorn.json')); + expectType(sync('unicorn.json')); })(); \ No newline at end of file From 3ad168d653dc22e5aefee4c2c5ab729dd9d09568 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 11 Sep 2018 16:22:56 +0700 Subject: [PATCH 19/21] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f6cc5e7..ecdd442 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "ava": "*", - "tsd-check": "*", + "tsd-check": "^0.2.1", "xo": "*" } } From a67eb2d06e7f0b6050c48d72133a6b6cf8ceca66 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 11 Sep 2018 16:23:28 +0700 Subject: [PATCH 20/21] Update index.test-d.ts --- index.test-d.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/index.test-d.ts b/index.test-d.ts index a9fb8b2..848393f 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,16 +1,14 @@ import {expectType} from 'tsd-check'; import loadJsonFile, {sync, Reviver, BeforeParse} from '.'; -(async () => { - // To-Do => Expand Tests - // https://github.com/sindresorhus/write-json-file/blob/master/index.test-d.ts - expectType(() => 1); - expectType((a: string) => a.length); - expectType((a: string, b: string) => a.length - b.length); +// To-Do => Expand Tests +// https://github.com/sindresorhus/write-json-file/blob/master/index.test-d.ts +expectType(() => 1); +expectType((a: string) => a.length); +expectType((a: string, b: string) => a.length - b.length); - expectType((data) => data); +expectType((data) => data); - expectType(await loadJsonFile('unicorn.json')); +expectType(await loadJsonFile('unicorn.json')); - expectType(sync('unicorn.json')); -})(); \ No newline at end of file +expectType(sync('unicorn.json')); From 1dfeeef5c754f3adad7312f2c18cfc3c70512052 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 18 Sep 2018 12:17:03 +0700 Subject: [PATCH 21/21] Update index.test-d.ts --- index.test-d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.test-d.ts b/index.test-d.ts index 848393f..aae4191 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,8 +1,6 @@ import {expectType} from 'tsd-check'; import loadJsonFile, {sync, Reviver, BeforeParse} from '.'; -// To-Do => Expand Tests -// https://github.com/sindresorhus/write-json-file/blob/master/index.test-d.ts expectType(() => 1); expectType((a: string) => a.length); expectType((a: string, b: string) => a.length - b.length);