Skip to content

Commit ac5b821

Browse files
TatsuyaYamamotosindresorhus
andauthoredAug 26, 2022
PackageJson: Add packageManager field (#446)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent eac8c6f commit ac5b821

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎source/package-json.d.ts

+20
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,25 @@ declare namespace PackageJson {
623623
};
624624
}
625625

626+
/**
627+
Type for [`package.json` file used by the Node.js runtime](https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions).
628+
*/
629+
export interface NodeJsStandard {
630+
/**
631+
Defines which package manager is expected to be used when working on the current project. It can set to any of the [supported package managers](https://nodejs.org/api/corepack.html#supported-package-managers), and will ensure that your teams use the exact same package manager versions without having to install anything else than Node.js.
632+
633+
__This field is currently experimental and needs to be opted-in; check the [Corepack](https://nodejs.org/api/corepack.html) page for details about the procedure.__
634+
635+
@example
636+
```json
637+
{
638+
"packageManager": "<package manager name>@<version>"
639+
}
640+
```
641+
*/
642+
packageManager?: string;
643+
}
644+
626645
export interface PublishConfig {
627646
/**
628647
Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig).
@@ -656,6 +675,7 @@ Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-j
656675
@category File
657676
*/
658677
export type PackageJson =
678+
PackageJson.NodeJsStandard &
659679
PackageJson.PackageJsonStandard &
660680
PackageJson.NonStandardEntryPoints &
661681
PackageJson.TypeScriptConfiguration &

‎test-d/package-json.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ expectType<PackageJson.Person[] | undefined>(packageJson.contributors);
1616
expectType<PackageJson.Person[] | undefined>(packageJson.maintainers);
1717
expectType<string[] | undefined>(packageJson.files);
1818
expectType<string | undefined>(packageJson.main);
19+
expectType<string | undefined>(packageJson.packageManager);
1920
expectType<string | Partial<Record<string, string>> | undefined>(packageJson.bin);
2021
expectType<string | undefined>(packageJson.types);
2122
expectType<string | undefined>(packageJson.typings);

0 commit comments

Comments
 (0)
Please sign in to comment.