Skip to content

Commit

Permalink
Add workspaces to PackageJson type
Browse files Browse the repository at this point in the history
  • Loading branch information
ifiokjr committed Feb 9, 2020
1 parent 7fe70fd commit 6c96bfa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions source/package-json.d.ts
Expand Up @@ -257,7 +257,39 @@ declare namespace PackageJson {
typings?: string;
}

/**
An alternative configuration for Yarn workspaces.
*/
export interface WorkspaceConfig {
/**
An array of workspace pattern strings which contain the workspace packages.
*/
packages?: WorkspacePattern[];
/**
`nohoist` is 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 packages which matches the pattern (https://classic.yarnpkg.com/blog/2018/02/15/nohoist/).
*/
nohoist?: WorkspacePattern[];
}

/**
A workspace pattern points to a folder or group of folders which contain packages that should be included in the workspace installation process. The patterns are handled with minimatch https://github.com/isaacs/minimatch
@example
`docs` -> Include the docs folder and install it's dependencies.
`packages/*` -> Include all nested folders within the packages folder like `packages/cli` and `packages/core`.
*/
type WorkspacePattern = string;

export interface 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 the top level `private` property of the `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`.
Expand Down
1 change: 1 addition & 0 deletions test-d/package-json.ts
Expand Up @@ -35,6 +35,7 @@ expectType<PackageJson.Dependency | undefined>(packageJson.peerDependencies);
expectType<string[] | undefined>(packageJson.bundleDependencies);
expectType<string[] | undefined>(packageJson.bundledDependencies);
expectType<PackageJson.Dependency | undefined>(packageJson.resolutions);
expectType<PackageJson.WorkspaceConfig | string[] | undefined>(packageJson.workspaces);
expectType<{[engineName: string]: string} | undefined>(packageJson.engines);
expectType<boolean | undefined>(packageJson.engineStrict);
expectType<
Expand Down

0 comments on commit 6c96bfa

Please sign in to comment.