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

Add PackageJson.PublishConfig type #205

Merged
Merged
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
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