Skip to content

Only allow @types packages in devDependencies

Only allow TypeScript @types packages from being used anywhere other than in the devDependencies section of package.json.

1. Add a version group

  • Match all dependencies whose name starts with @types/.
  • Only match those dependencies when they appear anywhere except devDependencies.
  • Define the behaviour of this group as isBanned.
  • Add a label to document the decision/expectation.
.syncpackrc
{
"versionGroups": [
{
"dependencies": ["@types/**"],
"dependencyTypes": ["!dev"],
"isBanned": true,
"label": "@types packages should only be under devDependencies"
}
]
}

2. Look for mismatches

Any @types packages which are in the wrong location can then be found and manually moved:

Terminal window
syncpack list-mismatches