mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
add normalized package type to read-pkg-up (#22730)
This commit is contained in:
committed by
Mohamed Hegazy
parent
7307351dc5
commit
8c3692c2c5
15
types/read-pkg-up/index.d.ts
vendored
15
types/read-pkg-up/index.d.ts
vendored
@@ -1,10 +1,14 @@
|
||||
// Type definitions for read-pkg-up 2.0
|
||||
// Type definitions for read-pkg-up 3.0
|
||||
// Project: https://github.com/sindresorhus/read-pkg-up
|
||||
// Definitions by: Louis Orleans <https://github.com/dudeofawesome>
|
||||
// Jeff Dickey <https://github.com/jdxcode>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import normalize = require('normalize-package-data');
|
||||
|
||||
declare namespace ReadPkgUp {
|
||||
function sync(options?: Options): Package;
|
||||
function sync(options: Options & {normalize: false}): {[k: string]: any};
|
||||
function sync(options?: Options): normalize.Package;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
@@ -21,11 +25,10 @@ declare namespace ReadPkgUp {
|
||||
normalize?: boolean;
|
||||
}
|
||||
|
||||
interface Package {
|
||||
[key: string]: any;
|
||||
}
|
||||
type Package = normalize.Package;
|
||||
}
|
||||
|
||||
declare function ReadPkgUp(options?: ReadPkgUp.Options): Promise<ReadPkgUp.Package>;
|
||||
declare function ReadPkgUp(options: ReadPkgUp.Options & {normalize: false}): Promise<{[k: string]: any}>;
|
||||
declare function ReadPkgUp(options?: ReadPkgUp.Options): Promise<normalize.Package>;
|
||||
|
||||
export = ReadPkgUp;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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';
|
||||
ReadPkgUp().then(pkg => pkg.name); // $ExpectType Promise<string>
|
||||
ReadPkgUp({cwd: '.', normalize: true}).then(pkg => pkg.name); // $ExpectType Promise<string>
|
||||
ReadPkgUp({cwd: '.', normalize: false}).then(pkg => pkg['name']); // $ExpectType Promise<any>
|
||||
ReadPkgUp.sync().name; // $ExpectType string
|
||||
ReadPkgUp.sync({cwd: '.', normalize: true}).name; // $ExpectType string
|
||||
ReadPkgUp.sync({cwd: '.', normalize: false})['name']; // $ExpectType any
|
||||
|
||||
Reference in New Issue
Block a user