From 7db4e171d46aae7a8ec850d77106bdabb84d8585 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Sun, 25 Dec 2022 17:05:03 -0600 Subject: [PATCH] `PackageJson`: Mention npm workspaces (#530) --- readme.md | 2 +- source/package-json.d.ts | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index 6a5d0b32..6b25615c 100644 --- a/readme.md +++ b/readme.md @@ -238,7 +238,7 @@ Click the type names for complete docs. ### Miscellaneous - [`GlobalThis`](source/global-this.d.ts) - Declare locally scoped properties on `globalThis`. -- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). It also includes support for [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) and [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/). +- [`PackageJson`](source/package-json.d.ts) - Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). It also includes support for [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html). - [`TsConfigJson`](source/tsconfig-json.d.ts) - Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html). ## Declined types diff --git a/source/package-json.d.ts b/source/package-json.d.ts index 824dbf4b..6d3dbed9 100644 --- a/source/package-json.d.ts +++ b/source/package-json.d.ts @@ -294,7 +294,7 @@ declare namespace PackageJson { }; /** - An alternative configuration for Yarn workspaces. + An alternative configuration for workspaces. */ export type WorkspaceConfig = { /** @@ -305,7 +305,8 @@ declare namespace PackageJson { /** Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns. - [Read more](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) + [Supported](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) by Yarn. + [Not supported](https://github.com/npm/rfcs/issues/287) by npm. */ nohoist?: WorkspacePattern[]; }; @@ -322,15 +323,6 @@ declare namespace PackageJson { type WorkspacePattern = string; export type YarnConfiguration = { - /** - Used to configure [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/). - - Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run `yarn install` once to install all of them in a single pass. - - Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces. - */ - workspaces?: WorkspacePattern[] | WorkspaceConfig; - /** If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command-line, set this to `true`. @@ -624,6 +616,15 @@ declare namespace PackageJson { */ url: string; }; + + /** + Used to configure [npm workspaces](https://docs.npmjs.com/cli/using-npm/workspaces) / [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/). + + Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run your install command once in order to install all of them in a single pass. + + Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces. + */ + workspaces?: WorkspacePattern[] | WorkspaceConfig; } /**