Skip to content

Commit

Permalink
Add PackageJson.PublishConfig type (#205)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
ryansonshine and sindresorhus authored May 7, 2021
1 parent 053563d commit 305795c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 27 additions & 1 deletion source/package-json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ declare namespace PackageJson {
/**
A set of config values that will be used at publish-time. It's especially handy to set the tag, registry or access, to ensure that a given package is not tagged with 'latest', published to the global public registry or that a scoped module is private by default.
*/
publishConfig?: Record<string, unknown>;
publishConfig?: PublishConfig;

/**
Describes and notifies consumers of a package's monetary support information.
Expand All @@ -598,6 +598,32 @@ declare namespace PackageJson {
url: string;
};
}

export interface PublishConfig {
/**
Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig).
*/
[additionalProperties: string]: unknown;

/**
When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.
*/
access?: 'public' | 'restricted';

/**
The base URL of the npm registry.
Default: `'https://registry.npmjs.org/'`
*/
registry?: string;

/**
The tag to publish the package under.
Default: `'latest'`
*/
tag?: string;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test-d/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ expectAssignable<
>(packageJson.cpu);
expectType<boolean | undefined>(packageJson.preferGlobal);
expectType<boolean | undefined>(packageJson.private);
expectType<Record<string, unknown> | undefined>(packageJson.publishConfig);
expectType<PackageJson.PublishConfig | undefined>(packageJson.publishConfig);
expectType<string | undefined>(packageJson.module);
expectType<
| string
Expand Down

0 comments on commit 305795c

Please sign in to comment.