Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include ./index.d.ts in the package. #486

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 100 additions & 26 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module NpmCheck {
declare module "npm-check" {
interface INpmCheckOptions {
global?: boolean;
update?: boolean;
Expand All @@ -10,42 +10,116 @@ declare module NpmCheck {
currentState?: Object;
}

type INpmCheckGetSetValues = "packages" | "debug" | "global" | "cwd" | "cwdPackageJson" | "emoji";
type INpmCheckGetSetValues =
| "packages"
| "debug"
| "global"
| "cwd"
| "cwdPackageJson"
| "emoji";

type INpmVersionBumpType = "patch" | "minor" | "major" | "prerelease" | "build" | "nonSemver" | null;
type INpmVersionBumpType =
| "patch"
| "minor"
| "major"
| "prerelease"
| "build"
| "nonSemver"
| null;

interface INpmCheckCurrentState {
get: (key: INpmCheckGetSetValues) => INpmCheckPackage[];
set: (key: INpmCheckGetSetValues, val: any) => void;
}

interface INpmCheckPackage {
moduleName: string; // name of the module.
homepage: string; // url to the home page.
regError: any; // error communicating with the registry
pkgError: any; // error reading the package.json
latest: string; // latest according to the registry.
installed: string; // version installed
isInstalled: boolean; // Is it installed?
notInstalled: boolean; // Is it installed?
packageWanted: string; // Requested version from the package.json.
packageJson: string; // Version or range requested in the parent package.json.
devDependency: boolean; // Is this a devDependency?
usedInScripts: undefined | string[], // Array of `scripts` in package.json that use this module.
mismatch: boolean; // Does the version installed not match the range in package.json?
semverValid: string; // Is the installed version valid semver?
easyUpgrade: boolean; // Will running just `npm install` upgrade the module?
bump: INpmVersionBumpType; // What kind of bump is required to get the latest
unused: boolean; // Is this module used in the code?
/**
* name of the module.
*/
moduleName: string;

/**
* url to the home page.
*/
homepage: string;

/**
* error communicating with the registry
*/
regError: any;

/**
* error reading the package.json
*/
pkgError: any;

/**
* latest according to the registry.
*/
latest: string;

/**
* version installed
*/
installed: string;

/**
* Is it installed?
*/
isInstalled: boolean;
/**
* Is it installed?
*/
notInstalled: boolean;

/**
* Requested version from the package.json.
*/
packageWanted: string;

/**
* Version or range requested in the parent package.json.
*/
packageJson: string;

/**
* Is this a devDependency?
*/
devDependency: boolean;

/**
* Array of `scripts` in package.json that use this module.
*/
usedInScripts: undefined | string[];

/**
* Does the version installed not match the range in package.json?
*/
mismatch: boolean;

/**
* Is the installed version valid semver?
*/
semverValid: string;

/**
* Will running just `npm install` upgrade the module?
*/
easyUpgrade: boolean;

/**
* What kind of bump is required to get the latest
*/
bump: INpmVersionBumpType;

/**
* Is this module used in the code?
*/
unused: boolean;
}

//The default function returns a promise
export default function(options: INpmCheckOptions): {
export default function (options: INpmCheckOptions): {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer equivalent, since the previous export used the CJS syntax.

We need to use the same syntax here to work as before:

Suggested change
export default function (options: INpmCheckOptions): {
export = function (options: INpmCheckOptions): {

Also, I think that we should remove the declare module block altogether. It only causes problems, and since this file is shipped next to index.js I don't see any reason why to have it?

then(stateFn: (state: INpmCheckCurrentState) => void): void;
};

}

declare module "npm-check" {
export = NpmCheck.default;
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"files": [
"bin",
"lib",
"lib-es5"
"lib-es5",
"index.d.ts"
],
"dependencies": {
"callsite-record": "^4.1.4",
Expand Down