Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

typesync

jeffijoe80.6kMIT0.14.0TypeScript support: included

Install missing TypeScript typings for your dependencies.

readme

TypeSync

Install missing TypeScript typings for dependencies in your package.json.

npm Build Status Coveralls npm license node

TypeSync

Install

npm install -g typesync

You can also use it directly with npx which will install it for you:

npx typesync

Usage

typesync [path/to/package.json] [--dry]

Path is relative to the current working directory. If omitted, defaults to package.json.

Note: TypeSync only modifies your package.json - you still need to run an installer.

--dry[=fail]

If --dry is specified, will not actually write to the file, it only prints added/removed typings.

The same is true for --dry=fail, with the additional effect of failing the command in case there are changes. This is useful for CI scenarios.

--ignoredeps

To ignore certain sections, you can use the --ignoredeps= flag. For example, to ignore devDependencies, use --ignoredeps=dev. To ignore multiple, comma-separate them, like this: --ignoredeps=deps,peer (ignores dependencies and peerDependencies).

  • --ignoredeps=deps — ignores dependencies
  • --ignoredeps=dev — ignores devDependencies
  • --ignoredeps=peer — ignores peerDependencies
  • --ignoredeps=optional — ignores optionalDependencies

--ignorepackages

To ignore certain packages, you can use the --ignorepackages= flag. For example, to ignore nodemon, use --ignorepackages=nodemon. To ignore multiple, comma-separate them, like this: --ignorepackages=nodemon,whatever (ignores nodemon and whatever).

Using a config file

Alternatively, you can use a TypeSync config file: .typesyncrc or a "typesync" section in your package.json. TypeSync will automatically search for configuration files. See cosmiconfig for details.

// .typesyncrc
{
  "ignoreDeps": ["dev"],
  "ignorePackages": ["nodemon"]
}

Run TypeSync automatically after every install

To run TypeSync and install packages automatically after every package install, create a file called install-with-types.sh with the following content:

npm install $1
npx typesync
npm install

If you use yarn, use this instead:

yarn add $1
yarn typesync
yarn

Run this command to make the file executable:

chmod +x install-with-types.sh

Add the following to package.json:

{
  "scripts": {
    "i": "./install-with-types.sh"
  }
}

Then install packages like this:

npm run i <pkg name>

# Or with Yarn:
yarn i <pkg name>

Typings packages

TypeSync will add typings for packages that:

  • have a @types/package available
  • don't already provide typings internally (the typings and types field in package.json)

TypeSync will try to respect SemVer parity for the code and typings packages, and will fall back to the latest available typings package.

When writing the typings package version to package.json, the ~ SemVer range is used. This is because typings published via DefinitelyTyped align typings versions with library versions using major and minor only.

For example, if you depend on react@^16.14.0, then TypeSync will only look for typings packages that match 16.14.*.

Monorepos

TypeSync added support for monorepos in v0.4.0. It will look at packages/workspaces globs in package.json and sync every matching file in one fell swoop.

Why?

Installing typings manually sucks. Flow has flow-typed which installs type definitions by looking at a package.json, which would be cool to have for TypeScript. Now we do!

Changelog

See CHANGELOG.md

Author

Jeff Hansen - @Jeffijoe

changelog

v0.14.0

  • #134: Modernize codebase with improved workspace handling, better glob functionality, and various fixes, @lishaduck
  • #135: Upgrade packages, @jeffijoe

v0.13.4

v0.13.3

v0.13.2

v0.13.1

v0.13.0

v0.12.2

  • #114: Fix check for deprecated packages.

v0.12.1

  • #106: Don't throw an error when unable to parse versions; default to the latest available one instead.
  • Upgrade packages.

v0.12.0

  • [BREAKING CHANGE] #86: Use the DefinitelyTyped strategy for resolving typings versions. This also means we no longer use the existing semver range specifier used in package.json.
  • [BREAKING CHANGE] Bump minimum supported Node version to 16.
  • The success message after running typesync now indicates when --dry is used.
  • Upgrade packages.

v0.11.1

  • #79: Ignore deprecated @typings/ packages.
  • Upgrade packages.

v0.11.0

  • Use npm-registry-fetch instead of axios for fetching package info from npm.
  • Microsoft removed their search-index resource, so will check npm directly.
  • Remove the "remove unused typings" feature as it relied on the information in the Microsoft index and isn't easily available elsewhere for the time being.
  • Update packages.

v0.10.0

v0.9.2

  • Update packages
  • #90: add index.ts

v0.9.1

  • --dry-fail should fail when either adding or removing typings (#87, @chelkyl)
  • Update packages

v0.9.0

  • BREAKING: Bump Node version to 12.
  • Update packages
  • #72: Add --dry-fail support (#83, @chelkyl)

v0.8.0

v0.7.0

  • Update packages
  • Bump engine version to 10.0
  • Ignore node_modules when globbing (#52, tanmen)

v0.6.1

  • Fix issue with unzipping, simply by not unzipping at all (#37)

v0.6.0

  • Automatically removes unused typings (#35)
  • --ignoredeps=<deps,dev,optional,peer> flag (#30)

v0.5.2

  • Updated packages (#31)

v0.5.1

  • Fix issue where TypeSync wouldn't start

v0.5.0

  • Don't install typings for packages that provide typings (#24)
  • Best-effort at respecting semver, falls back to latest (#25)
  • Add note about npx to README (#21)

v0.4.1

  • Support object variant of Yarn workspaces config.

v0.4.0

  • Support monorepos by reading packages/workspaces and syncing matching package.json files (#11)
  • Save typings with the same semver range specifier as the code package (#12)
  • Updated CLI output to accomodate syncing a monorepo

v0.3.1

  • Exclude test files from package

v0.3.0

  • Update packages

v0.2.5

  • Scoped package support

v0.2.4

  • Add note about running npm install or yarn

v0.2.3

  • Add engines field to package.json

v0.2.2

  • Fix typo in package name

v0.2.0

  • Preserve trailing newline when writing package.json to disk

v0.1.1

  • util.promisify polyfill for Node 6 support

v0.1.0

  • Initial release