• Stars
    star
    1,390
  • Rank 33,811 (Top 0.7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

typesync

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

npm dependency Status devDependency Status Build Status Coveralls npm npm 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 npm install, or — if drinking the k00laid — yarn.

--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

More Repositories

1

awilix

Extremely powerful Inversion of Control (IoC) container for Node.JS
TypeScript
2,999
star
2

koa-es7-boilerplate

A boilerplate for writing Koa 2 apps in ES7 with Babel.
JavaScript
272
star
3

mobx-task

Makes async function state management in MobX fun.
TypeScript
237
star
4

messageformat.net

ICU MessageFormat implementation for .NET.
C#
148
star
5

awilix-koa

Awilix helpers/middleware for Koa 2
TypeScript
129
star
6

yenv

Environment management for Node using YAML.
JavaScript
104
star
7

koa-respond

Koa middleware that adds useful methods to the context.
JavaScript
102
star
8

awilix-express

Awilix helpers/middleware for Express
TypeScript
101
star
9

libx

Collection + Model infrastructure for MobX applications.
TypeScript
99
star
10

httpclientgoodies.net

Useful utilities for the .NET HttpClient.
C#
62
star
11

snicket

Stream Store based on Postgres for Node.JS
TypeScript
40
star
12

screengun

A simple screen recorder for Windows based on ffmpeg
C#
39
star
13

fejl

Error-making utility for Node apps.
TypeScript
35
star
14

logpipe-server

The Logpipe server.
JavaScript
30
star
15

awilix-router-core

Reusable building blocks for writing Awilix router adapters for HTTP frameworks.
TypeScript
25
star
16

validx

Validation library for MobX.
TypeScript
23
star
17

keyblade

Fail fast when accessing undefined properties on objects.
JavaScript
14
star
18

npm-module-boilerplate

A boilerplate for authoring npm modules, with tests and linting.
JavaScript
10
star
19

skadi

A simple object validator/sanitizer based on `is-my-json-valid`.
JavaScript
9
star
20

deltio

A Google Cloud Pub/Sub emulator alternative, written in Rust.
Rust
8
star
21

dration

Duration utilities for JavaScript using primitive types.
TypeScript
6
star
22

icebug

A wrapper around node-inspector and nodemon.
JavaScript
4
star
23

jQuery-Validator.Knockout

KnockoutJS bindings for my jQuery-Validator.
JavaScript
4
star
24

bristol-sentry

Sentry integration for the Bristol logger
JavaScript
3
star
25

smid

Catches errors and returns them. Useful for unit testing.
TypeScript
3
star
26

baconpi-web

BaconPi Web Frontend + Backend
JavaScript
3
star
27

ts-module-boilerplate

TypeScript module boilerplate for Node packages
TypeScript
3
star
28

posish

A tool that makes counting string lines, columns and indexes awesome. Useful for writing parser tests.
JavaScript
2
star
29

total-rename

Utility to replace strings in files and paths.
Go
2
star
30

purge

Windows utility for deleting a directory tree with long paths.
C#
1
star
31

chilli

Rename files to sort-friendly numbers
F#
1
star
32

jQuery-Validator

A formless validation plugin for all kinds of validation - even your own!
JavaScript
1
star