From 2a9da2fbf54b9c98298167d1dbd0dba4c1dc49e4 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Tue, 19 Sep 2017 14:23:12 -0700 Subject: [PATCH 1/5] feat(read-pkg-up): add types --- types/read-pkg-up/index.d.ts | 31 ++++++++++++++++++++++++++ types/read-pkg-up/read-pkg-up-tests.ts | 4 ++++ types/read-pkg-up/tsconfig.json | 22 ++++++++++++++++++ types/read-pkg-up/tslint.json | 1 + 4 files changed, 58 insertions(+) create mode 100644 types/read-pkg-up/index.d.ts create mode 100644 types/read-pkg-up/read-pkg-up-tests.ts create mode 100644 types/read-pkg-up/tsconfig.json create mode 100644 types/read-pkg-up/tslint.json diff --git a/types/read-pkg-up/index.d.ts b/types/read-pkg-up/index.d.ts new file mode 100644 index 0000000000..974a9fa0cd --- /dev/null +++ b/types/read-pkg-up/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for read-pkg-up 2.0 +// Project: https://github.com/sindresorhus/read-pkg-up +// Definitions by: Louis Orleans +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace ReadPkgUp { + function sync(options?: Options): Package; + + interface Options { + /** + * Directory to start looking for a package.json file. + * + * @default 'process.cwd()' + */ + cwd?: string; + /** + * [Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data. + * + * @default true + */ + normalize?: boolean; + } + + interface Package { + [key: string]: any; + } +} + +declare function ReadPkgUp(options?: ReadPkgUp.Options): Promise; + +export = ReadPkgUp; diff --git a/types/read-pkg-up/read-pkg-up-tests.ts b/types/read-pkg-up/read-pkg-up-tests.ts new file mode 100644 index 0000000000..5e7d4bdccf --- /dev/null +++ b/types/read-pkg-up/read-pkg-up-tests.ts @@ -0,0 +1,4 @@ +import * as ReadPkgUp from 'read-pkg-up'; + +ReadPkgUp({cwd: '.', normalize: false}).then(pkg => typeof pkg === 'object'); +typeof ReadPkgUp.sync({cwd: '.', normalize: false}) === 'object'; diff --git a/types/read-pkg-up/tsconfig.json b/types/read-pkg-up/tsconfig.json new file mode 100644 index 0000000000..e963194ea4 --- /dev/null +++ b/types/read-pkg-up/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "read-pkg-up-tests.ts" + ] +} diff --git a/types/read-pkg-up/tslint.json b/types/read-pkg-up/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/read-pkg-up/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 105b5938545da389600c0f961bb81e5c36f0d0e7 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Tue, 19 Sep 2017 14:27:39 -0700 Subject: [PATCH 2/5] fix(read-pkg-up): set strictNullChecks true --- types/read-pkg-up/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/read-pkg-up/tsconfig.json b/types/read-pkg-up/tsconfig.json index e963194ea4..58be3b23c7 100644 --- a/types/read-pkg-up/tsconfig.json +++ b/types/read-pkg-up/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From d1d159380437299fd1fe0645447da7a5eda3928f Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Wed, 20 Sep 2017 11:17:25 -0700 Subject: [PATCH 3/5] fix(read-pkg-up): make requested changes --- types/read-pkg-up/index.d.ts | 6 +++--- types/read-pkg-up/read-pkg-up-tests.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/read-pkg-up/index.d.ts b/types/read-pkg-up/index.d.ts index 974a9fa0cd..f1c7bd11ee 100644 --- a/types/read-pkg-up/index.d.ts +++ b/types/read-pkg-up/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace ReadPkgUp { - function sync(options?: Options): Package; + export function sync(options?: Options): Package; - interface Options { + export interface Options { /** * Directory to start looking for a package.json file. * @@ -21,7 +21,7 @@ declare namespace ReadPkgUp { normalize?: boolean; } - interface Package { + export interface Package { [key: string]: any; } } diff --git a/types/read-pkg-up/read-pkg-up-tests.ts b/types/read-pkg-up/read-pkg-up-tests.ts index 5e7d4bdccf..e01dd4e123 100644 --- a/types/read-pkg-up/read-pkg-up-tests.ts +++ b/types/read-pkg-up/read-pkg-up-tests.ts @@ -1,4 +1,4 @@ -import * as ReadPkgUp from 'read-pkg-up'; +import ReadPkgUp = require('read-pkg-up'); ReadPkgUp({cwd: '.', normalize: false}).then(pkg => typeof pkg === 'object'); typeof ReadPkgUp.sync({cwd: '.', normalize: false}) === 'object'; From 531da5fc783fb49b704af1bef4f6d2b30a01f543 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Wed, 20 Sep 2017 11:19:12 -0700 Subject: [PATCH 4/5] test(read-pkg-up): adds more complete tests --- types/read-pkg-up/read-pkg-up-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/read-pkg-up/read-pkg-up-tests.ts b/types/read-pkg-up/read-pkg-up-tests.ts index e01dd4e123..f536f275d2 100644 --- a/types/read-pkg-up/read-pkg-up-tests.ts +++ b/types/read-pkg-up/read-pkg-up-tests.ts @@ -1,4 +1,6 @@ import ReadPkgUp = require('read-pkg-up'); +ReadPkgUp().then(pkg => typeof pkg === 'object'); ReadPkgUp({cwd: '.', normalize: false}).then(pkg => typeof pkg === 'object'); +typeof ReadPkgUp.sync() === 'object'; typeof ReadPkgUp.sync({cwd: '.', normalize: false}) === 'object'; From 3f097b81339050b9d1ae895d709d054d66b6ac3d Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Wed, 20 Sep 2017 12:06:10 -0700 Subject: [PATCH 5/5] style(read-pkg-up): fix linting --- types/read-pkg-up/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/read-pkg-up/index.d.ts b/types/read-pkg-up/index.d.ts index f1c7bd11ee..974a9fa0cd 100644 --- a/types/read-pkg-up/index.d.ts +++ b/types/read-pkg-up/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace ReadPkgUp { - export function sync(options?: Options): Package; + function sync(options?: Options): Package; - export interface Options { + interface Options { /** * Directory to start looking for a package.json file. * @@ -21,7 +21,7 @@ declare namespace ReadPkgUp { normalize?: boolean; } - export interface Package { + interface Package { [key: string]: any; } }